@wundr.io/cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +551 -0
- package/bin/wundr.js +39 -0
- package/dist/ai/ai-service.d.ts +152 -0
- package/dist/ai/ai-service.d.ts.map +1 -0
- package/dist/ai/ai-service.js +430 -0
- package/dist/ai/ai-service.js.map +1 -0
- package/dist/ai/claude-client.d.ts +130 -0
- package/dist/ai/claude-client.d.ts.map +1 -0
- package/dist/ai/claude-client.js +339 -0
- package/dist/ai/claude-client.js.map +1 -0
- package/dist/ai/conversation-manager.d.ts +164 -0
- package/dist/ai/conversation-manager.d.ts.map +1 -0
- package/dist/ai/conversation-manager.js +612 -0
- package/dist/ai/conversation-manager.js.map +1 -0
- package/dist/ai/index.d.ts +5 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +8 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/cli.d.ts +36 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +173 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/ai.d.ts +89 -0
- package/dist/commands/ai.d.ts.map +1 -0
- package/dist/commands/ai.js +735 -0
- package/dist/commands/ai.js.map +1 -0
- package/dist/commands/analyze-optimized.d.ts +14 -0
- package/dist/commands/analyze-optimized.d.ts.map +1 -0
- package/dist/commands/analyze-optimized.js +437 -0
- package/dist/commands/analyze-optimized.js.map +1 -0
- package/dist/commands/analyze.d.ts +65 -0
- package/dist/commands/analyze.d.ts.map +1 -0
- package/dist/commands/analyze.js +435 -0
- package/dist/commands/analyze.js.map +1 -0
- package/dist/commands/batch.d.ts +71 -0
- package/dist/commands/batch.d.ts.map +1 -0
- package/dist/commands/batch.js +738 -0
- package/dist/commands/batch.js.map +1 -0
- package/dist/commands/chat.d.ts +71 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +674 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/claude-init.d.ts +28 -0
- package/dist/commands/claude-init.d.ts.map +1 -0
- package/dist/commands/claude-init.js +587 -0
- package/dist/commands/claude-init.js.map +1 -0
- package/dist/commands/claude-setup.d.ts +32 -0
- package/dist/commands/claude-setup.d.ts.map +1 -0
- package/dist/commands/claude-setup.js +570 -0
- package/dist/commands/claude-setup.js.map +1 -0
- package/dist/commands/computer-setup-commands.d.ts +39 -0
- package/dist/commands/computer-setup-commands.d.ts.map +1 -0
- package/dist/commands/computer-setup-commands.js +563 -0
- package/dist/commands/computer-setup-commands.js.map +1 -0
- package/dist/commands/computer-setup.d.ts +7 -0
- package/dist/commands/computer-setup.d.ts.map +1 -0
- package/dist/commands/computer-setup.js +481 -0
- package/dist/commands/computer-setup.js.map +1 -0
- package/dist/commands/create-command.d.ts +7 -0
- package/dist/commands/create-command.d.ts.map +1 -0
- package/dist/commands/create-command.js +158 -0
- package/dist/commands/create-command.js.map +1 -0
- package/dist/commands/create.d.ts +74 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +556 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dashboard.d.ts +91 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +537 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/govern.d.ts +70 -0
- package/dist/commands/govern.d.ts.map +1 -0
- package/dist/commands/govern.js +480 -0
- package/dist/commands/govern.js.map +1 -0
- package/dist/commands/init.d.ts +55 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +584 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/performance-optimizer.d.ts +30 -0
- package/dist/commands/performance-optimizer.d.ts.map +1 -0
- package/dist/commands/performance-optimizer.js +649 -0
- package/dist/commands/performance-optimizer.js.map +1 -0
- package/dist/commands/plugins.d.ts +87 -0
- package/dist/commands/plugins.d.ts.map +1 -0
- package/dist/commands/plugins.js +685 -0
- package/dist/commands/plugins.js.map +1 -0
- package/dist/commands/setup.d.ts +29 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +399 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/test-init.d.ts +9 -0
- package/dist/commands/test-init.d.ts.map +1 -0
- package/dist/commands/test-init.js +222 -0
- package/dist/commands/test-init.js.map +1 -0
- package/dist/commands/test.d.ts +25 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +217 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/watch.d.ts +76 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +610 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/context/context-manager.d.ts +155 -0
- package/dist/context/context-manager.d.ts.map +1 -0
- package/dist/context/context-manager.js +383 -0
- package/dist/context/context-manager.js.map +1 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/context/index.js +6 -0
- package/dist/context/index.js.map +1 -0
- package/dist/context/session-manager.d.ts +207 -0
- package/dist/context/session-manager.d.ts.map +1 -0
- package/dist/context/session-manager.js +682 -0
- package/dist/context/session-manager.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/interactive/interactive-mode.d.ts +76 -0
- package/dist/interactive/interactive-mode.d.ts.map +1 -0
- package/dist/interactive/interactive-mode.js +730 -0
- package/dist/interactive/interactive-mode.js.map +1 -0
- package/dist/nlp/command-mapper.d.ts +174 -0
- package/dist/nlp/command-mapper.d.ts.map +1 -0
- package/dist/nlp/command-mapper.js +623 -0
- package/dist/nlp/command-mapper.js.map +1 -0
- package/dist/nlp/command-parser.d.ts +106 -0
- package/dist/nlp/command-parser.d.ts.map +1 -0
- package/dist/nlp/command-parser.js +416 -0
- package/dist/nlp/command-parser.js.map +1 -0
- package/dist/nlp/index.d.ts +5 -0
- package/dist/nlp/index.d.ts.map +1 -0
- package/dist/nlp/index.js +8 -0
- package/dist/nlp/index.js.map +1 -0
- package/dist/nlp/intent-classifier.d.ts +59 -0
- package/dist/nlp/intent-classifier.d.ts.map +1 -0
- package/dist/nlp/intent-classifier.js +384 -0
- package/dist/nlp/intent-classifier.js.map +1 -0
- package/dist/nlp/intent-parser.d.ts +152 -0
- package/dist/nlp/intent-parser.d.ts.map +1 -0
- package/dist/nlp/intent-parser.js +739 -0
- package/dist/nlp/intent-parser.js.map +1 -0
- package/dist/plugins/plugin-manager.d.ts +120 -0
- package/dist/plugins/plugin-manager.d.ts.map +1 -0
- package/dist/plugins/plugin-manager.js +595 -0
- package/dist/plugins/plugin-manager.js.map +1 -0
- package/dist/types/index.d.ts +224 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/config-manager.d.ts +73 -0
- package/dist/utils/config-manager.d.ts.map +1 -0
- package/dist/utils/config-manager.js +339 -0
- package/dist/utils/config-manager.js.map +1 -0
- package/dist/utils/error-handler.d.ts +46 -0
- package/dist/utils/error-handler.d.ts.map +1 -0
- package/dist/utils/error-handler.js +169 -0
- package/dist/utils/error-handler.js.map +1 -0
- package/dist/utils/logger.d.ts +25 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +94 -0
- package/dist/utils/logger.js.map +1 -0
- package/package.json +119 -0
- package/src/ai/ai-service.ts +595 -0
- package/src/ai/claude-client.ts +490 -0
- package/src/ai/conversation-manager.ts +907 -0
- package/src/ai/index.ts +8 -0
- package/src/cli.ts +202 -0
- package/src/commands/ai.ts +995 -0
- package/src/commands/analyze-optimized.ts +641 -0
- package/src/commands/analyze.ts +576 -0
- package/src/commands/batch.ts +935 -0
- package/src/commands/chat.ts +876 -0
- package/src/commands/claude-init.ts +715 -0
- package/src/commands/claude-setup.ts +697 -0
- package/src/commands/computer-setup-commands.ts +709 -0
- package/src/commands/computer-setup.ts +565 -0
- package/src/commands/create-command.ts +175 -0
- package/src/commands/create.ts +727 -0
- package/src/commands/dashboard.ts +691 -0
- package/src/commands/govern.ts +635 -0
- package/src/commands/init.ts +677 -0
- package/src/commands/performance-optimizer.ts +864 -0
- package/src/commands/plugins.ts +848 -0
- package/src/commands/setup.ts +508 -0
- package/src/commands/test-init.ts +242 -0
- package/src/commands/test.ts +264 -0
- package/src/commands/watch.ts +755 -0
- package/src/context/context-manager.ts +546 -0
- package/src/context/index.ts +9 -0
- package/src/context/session-manager.ts +1019 -0
- package/src/index.ts +64 -0
- package/src/interactive/interactive-mode.ts +830 -0
- package/src/nlp/command-mapper.ts +885 -0
- package/src/nlp/command-parser.ts +564 -0
- package/src/nlp/index.ts +4 -0
- package/src/nlp/intent-classifier.ts +458 -0
- package/src/nlp/intent-parser.ts +1101 -0
- package/src/plugins/plugin-manager.ts +744 -0
- package/src/types/index.ts +252 -0
- package/src/types/modules.d.ts +56 -0
- package/src/utils/config-manager.ts +391 -0
- package/src/utils/error-handler.ts +192 -0
- package/src/utils/logger.ts +104 -0
- package/templates/batch/ci-cd.yaml +62 -0
- package/templates/component/{{fileName}}.test.tsx +17 -0
- package/templates/component/{{fileName}}.tsx +21 -0
- package/templates/service/{{fileName}}.ts +98 -0
- package/templates/wundr-test.config.js +0 -0
- package/test-suites/api/health.spec.ts +134 -0
- package/test-suites/helpers/test-config.ts +84 -0
- package/test-suites/ui/accessibility.spec.ts +102 -0
- package/test-suites/ui/smoke.spec.ts +92 -0
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
|
+
// import path from 'path'; // Unused import
|
|
4
|
+
import chalk from 'chalk';
|
|
5
|
+
import { ConfigManager } from '../utils/config-manager';
|
|
6
|
+
import { PluginManager } from '../plugins/plugin-manager';
|
|
7
|
+
import { logger } from '../utils/logger';
|
|
8
|
+
import { errorHandler } from '../utils/error-handler';
|
|
9
|
+
import { AnalysisResult, Finding } from '../types';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Analyze commands for code analysis and dependency management
|
|
13
|
+
*/
|
|
14
|
+
export class AnalyzeCommands {
|
|
15
|
+
constructor(
|
|
16
|
+
private program: Command,
|
|
17
|
+
private _configManager: ConfigManager,
|
|
18
|
+
private _pluginManager: PluginManager
|
|
19
|
+
) {
|
|
20
|
+
this.registerCommands();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private registerCommands(): void {
|
|
24
|
+
const analyzeCmd = this.program
|
|
25
|
+
.command('analyze')
|
|
26
|
+
.description('analyze code dependencies, quality, and performance');
|
|
27
|
+
|
|
28
|
+
// Analyze dependencies
|
|
29
|
+
analyzeCmd
|
|
30
|
+
.command('deps')
|
|
31
|
+
.alias('dependencies')
|
|
32
|
+
.description('analyze project dependencies')
|
|
33
|
+
.option('--circular', 'detect circular dependencies')
|
|
34
|
+
.option('--unused', 'find unused dependencies')
|
|
35
|
+
.option('--outdated', 'check for outdated packages')
|
|
36
|
+
.option('--security', 'run security audit')
|
|
37
|
+
.option(
|
|
38
|
+
'--format <format>',
|
|
39
|
+
'output format (json, table, graph)',
|
|
40
|
+
'table'
|
|
41
|
+
)
|
|
42
|
+
.action(async options => {
|
|
43
|
+
await this.analyzeDependencies(options);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Analyze code quality
|
|
47
|
+
analyzeCmd
|
|
48
|
+
.command('quality')
|
|
49
|
+
.alias('code')
|
|
50
|
+
.description('analyze code quality metrics')
|
|
51
|
+
.option('--complexity', 'analyze code complexity')
|
|
52
|
+
.option('--duplication', 'detect code duplication')
|
|
53
|
+
.option('--coverage', 'analyze test coverage')
|
|
54
|
+
.option('--metrics', 'generate quality metrics')
|
|
55
|
+
.action(async options => {
|
|
56
|
+
await this.analyzeQuality(options);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Analyze performance
|
|
60
|
+
analyzeCmd
|
|
61
|
+
.command('perf')
|
|
62
|
+
.alias('performance')
|
|
63
|
+
.description('analyze performance metrics')
|
|
64
|
+
.option('--bundle', 'analyze bundle size')
|
|
65
|
+
.option('--runtime', 'analyze runtime performance')
|
|
66
|
+
.option('--memory', 'analyze memory usage')
|
|
67
|
+
.action(async options => {
|
|
68
|
+
await this.analyzePerformance(options);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// Analyze architecture
|
|
72
|
+
analyzeCmd
|
|
73
|
+
.command('arch')
|
|
74
|
+
.alias('architecture')
|
|
75
|
+
.description('analyze project architecture')
|
|
76
|
+
.option('--structure', 'analyze project structure')
|
|
77
|
+
.option('--patterns', 'detect architectural patterns')
|
|
78
|
+
.option('--violations', 'find architectural violations')
|
|
79
|
+
.action(async options => {
|
|
80
|
+
await this.analyzeArchitecture(options);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
// Full analysis
|
|
84
|
+
analyzeCmd
|
|
85
|
+
.command('all')
|
|
86
|
+
.description('run all analysis types')
|
|
87
|
+
.option('--report', 'generate comprehensive report')
|
|
88
|
+
.option('--export <path>', 'export results to file')
|
|
89
|
+
.action(async options => {
|
|
90
|
+
await this.analyzeAll(options);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// Scan for issues
|
|
94
|
+
analyzeCmd
|
|
95
|
+
.command('scan [path]')
|
|
96
|
+
.description('scan directory for issues')
|
|
97
|
+
.option('--rules <rules>', 'custom rules to apply')
|
|
98
|
+
.option('--severity <level>', 'minimum severity level', 'warning')
|
|
99
|
+
.option('--fix', 'automatically fix issues where possible')
|
|
100
|
+
.action(async (scanPath, options) => {
|
|
101
|
+
await this.scanForIssues(scanPath || process.cwd(), options);
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Analyze project dependencies
|
|
107
|
+
*/
|
|
108
|
+
private async analyzeDependencies(options: any): Promise<void> {
|
|
109
|
+
try {
|
|
110
|
+
logger.info('Analyzing dependencies...');
|
|
111
|
+
|
|
112
|
+
const results: AnalysisResult = {
|
|
113
|
+
type: 'dependency',
|
|
114
|
+
findings: [],
|
|
115
|
+
metrics: {},
|
|
116
|
+
recommendations: [],
|
|
117
|
+
timestamp: new Date(),
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
if (options.circular) {
|
|
121
|
+
const circularDeps = await this.detectCircularDependencies();
|
|
122
|
+
results.findings.push(...circularDeps);
|
|
123
|
+
logger.info(`Found ${circularDeps.length} circular dependencies`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (options.unused) {
|
|
127
|
+
const unusedDeps = await this.findUnusedDependencies();
|
|
128
|
+
results.findings.push(...unusedDeps);
|
|
129
|
+
logger.info(`Found ${unusedDeps.length} unused dependencies`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (options.outdated) {
|
|
133
|
+
const outdatedDeps = await this.checkOutdatedPackages();
|
|
134
|
+
results.findings.push(...outdatedDeps);
|
|
135
|
+
logger.info(`Found ${outdatedDeps.length} outdated packages`);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (options.security) {
|
|
139
|
+
const securityIssues = await this.runSecurityAudit();
|
|
140
|
+
results.findings.push(...securityIssues);
|
|
141
|
+
logger.info(`Found ${securityIssues.length} security issues`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
await this.outputResults(results, options.format);
|
|
145
|
+
logger.success('Dependency analysis completed');
|
|
146
|
+
} catch (error) {
|
|
147
|
+
throw errorHandler.createError(
|
|
148
|
+
'WUNDR_ANALYZE_DEPS_FAILED',
|
|
149
|
+
'Failed to analyze dependencies',
|
|
150
|
+
{ options },
|
|
151
|
+
true
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Analyze code quality
|
|
158
|
+
*/
|
|
159
|
+
private async analyzeQuality(options: any): Promise<void> {
|
|
160
|
+
try {
|
|
161
|
+
logger.info('Analyzing code quality...');
|
|
162
|
+
|
|
163
|
+
const results: AnalysisResult = {
|
|
164
|
+
type: 'quality',
|
|
165
|
+
findings: [],
|
|
166
|
+
metrics: {},
|
|
167
|
+
recommendations: [],
|
|
168
|
+
timestamp: new Date(),
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
if (options['complexity']) {
|
|
172
|
+
const complexity = await this.analyzeComplexity();
|
|
173
|
+
results.metrics['complexity'] = complexity.average;
|
|
174
|
+
results.findings.push(...complexity.violations);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (options['duplication']) {
|
|
178
|
+
const duplication = await this.detectDuplication();
|
|
179
|
+
results.metrics['duplication'] = duplication.percentage;
|
|
180
|
+
results.findings.push(...duplication.violations);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (options['coverage']) {
|
|
184
|
+
const coverage = await this.analyzeCoverage();
|
|
185
|
+
results.metrics['coverage'] = coverage.percentage;
|
|
186
|
+
results.findings.push(...coverage.violations);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (options.metrics) {
|
|
190
|
+
const metrics = await this.generateQualityMetrics();
|
|
191
|
+
Object.assign(results.metrics, metrics);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
await this.outputResults(results, 'table');
|
|
195
|
+
logger.success('Quality analysis completed');
|
|
196
|
+
} catch (error) {
|
|
197
|
+
throw errorHandler.createError(
|
|
198
|
+
'WUNDR_ANALYZE_QUALITY_FAILED',
|
|
199
|
+
'Failed to analyze code quality',
|
|
200
|
+
{ options },
|
|
201
|
+
true
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Analyze performance
|
|
208
|
+
*/
|
|
209
|
+
private async analyzePerformance(options: any): Promise<void> {
|
|
210
|
+
try {
|
|
211
|
+
logger.info('Analyzing performance...');
|
|
212
|
+
|
|
213
|
+
const results: AnalysisResult = {
|
|
214
|
+
type: 'performance',
|
|
215
|
+
findings: [],
|
|
216
|
+
metrics: {},
|
|
217
|
+
recommendations: [],
|
|
218
|
+
timestamp: new Date(),
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
if (options.bundle) {
|
|
222
|
+
const bundleAnalysis = await this.analyzeBundleSize();
|
|
223
|
+
results.metrics['bundleSize'] = bundleAnalysis.totalSize;
|
|
224
|
+
results.findings.push(...bundleAnalysis.issues);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (options.runtime) {
|
|
228
|
+
const runtimeAnalysis = await this.analyzeRuntimePerformance();
|
|
229
|
+
results.metrics['runtime'] = runtimeAnalysis.averageTime;
|
|
230
|
+
results.findings.push(...runtimeAnalysis.issues);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (options.memory) {
|
|
234
|
+
const memoryAnalysis = await this.analyzeMemoryUsage();
|
|
235
|
+
results.metrics['memory'] = memoryAnalysis.peakUsage;
|
|
236
|
+
results.findings.push(...memoryAnalysis.issues);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
await this.outputResults(results, 'table');
|
|
240
|
+
logger.success('Performance analysis completed');
|
|
241
|
+
} catch (error) {
|
|
242
|
+
throw errorHandler.createError(
|
|
243
|
+
'WUNDR_ANALYZE_PERF_FAILED',
|
|
244
|
+
'Failed to analyze performance',
|
|
245
|
+
{ options },
|
|
246
|
+
true
|
|
247
|
+
);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Analyze architecture
|
|
253
|
+
*/
|
|
254
|
+
private async analyzeArchitecture(options: any): Promise<void> {
|
|
255
|
+
try {
|
|
256
|
+
logger.info('Analyzing architecture...');
|
|
257
|
+
|
|
258
|
+
const results: AnalysisResult = {
|
|
259
|
+
type: 'dependency',
|
|
260
|
+
findings: [],
|
|
261
|
+
metrics: {},
|
|
262
|
+
recommendations: [],
|
|
263
|
+
timestamp: new Date(),
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
if (options.structure) {
|
|
267
|
+
const structure = await this.analyzeProjectStructure();
|
|
268
|
+
results.findings.push(...structure.violations);
|
|
269
|
+
results.recommendations.push(...structure.recommendations);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (options.patterns) {
|
|
273
|
+
const patterns = await this.detectArchitecturalPatterns();
|
|
274
|
+
results.findings.push(...patterns.violations);
|
|
275
|
+
results.recommendations.push(...patterns.recommendations);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (options.violations) {
|
|
279
|
+
const violations = await this.findArchitecturalViolations();
|
|
280
|
+
results.findings.push(...violations);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
await this.outputResults(results, 'table');
|
|
284
|
+
logger.success('Architecture analysis completed');
|
|
285
|
+
} catch (error) {
|
|
286
|
+
throw errorHandler.createError(
|
|
287
|
+
'WUNDR_ANALYZE_ARCH_FAILED',
|
|
288
|
+
'Failed to analyze architecture',
|
|
289
|
+
{ options },
|
|
290
|
+
true
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Run all analysis types
|
|
297
|
+
*/
|
|
298
|
+
private async analyzeAll(options: any): Promise<void> {
|
|
299
|
+
try {
|
|
300
|
+
logger.info('Running comprehensive analysis...');
|
|
301
|
+
|
|
302
|
+
const allResults: AnalysisResult[] = [];
|
|
303
|
+
|
|
304
|
+
// Run all analysis types
|
|
305
|
+
await this.analyzeDependencies({
|
|
306
|
+
circular: true,
|
|
307
|
+
unused: true,
|
|
308
|
+
security: true,
|
|
309
|
+
});
|
|
310
|
+
await this.analyzeQuality({
|
|
311
|
+
complexity: true,
|
|
312
|
+
duplication: true,
|
|
313
|
+
coverage: true,
|
|
314
|
+
});
|
|
315
|
+
await this.analyzePerformance({ bundle: true, runtime: true });
|
|
316
|
+
await this.analyzeArchitecture({ structure: true, patterns: true });
|
|
317
|
+
|
|
318
|
+
if (options.report) {
|
|
319
|
+
await this.generateComprehensiveReport(allResults);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (options.export) {
|
|
323
|
+
await this.exportResults(allResults, options.export);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
logger.success('Comprehensive analysis completed');
|
|
327
|
+
} catch (error) {
|
|
328
|
+
throw errorHandler.createError(
|
|
329
|
+
'WUNDR_ANALYZE_ALL_FAILED',
|
|
330
|
+
'Failed to run comprehensive analysis',
|
|
331
|
+
{ options },
|
|
332
|
+
true
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Scan for issues in directory
|
|
339
|
+
*/
|
|
340
|
+
private async scanForIssues(scanPath: string, options: any): Promise<void> {
|
|
341
|
+
try {
|
|
342
|
+
logger.info(`Scanning ${chalk.cyan(scanPath)} for issues...`);
|
|
343
|
+
|
|
344
|
+
const findings = await this.performDirectoryScan(scanPath, options);
|
|
345
|
+
|
|
346
|
+
if (options.fix) {
|
|
347
|
+
const fixedCount = await this.autoFixIssues(findings);
|
|
348
|
+
logger.success(`Fixed ${fixedCount} issues automatically`);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const results: AnalysisResult = {
|
|
352
|
+
type: 'quality',
|
|
353
|
+
findings,
|
|
354
|
+
metrics: { totalIssues: findings.length },
|
|
355
|
+
recommendations: [],
|
|
356
|
+
timestamp: new Date(),
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
await this.outputResults(results, 'table');
|
|
360
|
+
logger.success(`Scan completed: ${findings.length} issues found`);
|
|
361
|
+
} catch (error) {
|
|
362
|
+
throw errorHandler.createError(
|
|
363
|
+
'WUNDR_SCAN_FAILED',
|
|
364
|
+
'Failed to scan for issues',
|
|
365
|
+
{ scanPath, options },
|
|
366
|
+
true
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Analysis implementation methods
|
|
373
|
+
*/
|
|
374
|
+
private async detectCircularDependencies(): Promise<Finding[]> {
|
|
375
|
+
const findings: Finding[] = [];
|
|
376
|
+
|
|
377
|
+
// Implementation for detecting circular dependencies
|
|
378
|
+
// This would integrate with existing analysis tools
|
|
379
|
+
|
|
380
|
+
return findings;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
private async findUnusedDependencies(): Promise<Finding[]> {
|
|
384
|
+
const findings: Finding[] = [];
|
|
385
|
+
|
|
386
|
+
// Implementation for finding unused dependencies
|
|
387
|
+
// This would analyze package.json and actual usage
|
|
388
|
+
|
|
389
|
+
return findings;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
private async checkOutdatedPackages(): Promise<Finding[]> {
|
|
393
|
+
const findings: Finding[] = [];
|
|
394
|
+
|
|
395
|
+
// Implementation for checking outdated packages
|
|
396
|
+
// This would check npm registry for newer versions
|
|
397
|
+
|
|
398
|
+
return findings;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
private async runSecurityAudit(): Promise<Finding[]> {
|
|
402
|
+
const findings: Finding[] = [];
|
|
403
|
+
|
|
404
|
+
// Implementation for security audit
|
|
405
|
+
// This would use npm audit or similar tools
|
|
406
|
+
|
|
407
|
+
return findings;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
private async analyzeComplexity(): Promise<{
|
|
411
|
+
average: number;
|
|
412
|
+
violations: Finding[];
|
|
413
|
+
}> {
|
|
414
|
+
// Implementation for complexity analysis
|
|
415
|
+
return { average: 0, violations: [] };
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
private async detectDuplication(): Promise<{
|
|
419
|
+
percentage: number;
|
|
420
|
+
violations: Finding[];
|
|
421
|
+
}> {
|
|
422
|
+
// Implementation for duplication detection
|
|
423
|
+
return { percentage: 0, violations: [] };
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
private async analyzeCoverage(): Promise<{
|
|
427
|
+
percentage: number;
|
|
428
|
+
violations: Finding[];
|
|
429
|
+
}> {
|
|
430
|
+
// Implementation for coverage analysis
|
|
431
|
+
return { percentage: 0, violations: [] };
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
private async generateQualityMetrics(): Promise<Record<string, number>> {
|
|
435
|
+
// Implementation for quality metrics
|
|
436
|
+
return {};
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
private async analyzeBundleSize(): Promise<{
|
|
440
|
+
totalSize: number;
|
|
441
|
+
issues: Finding[];
|
|
442
|
+
}> {
|
|
443
|
+
// Implementation for bundle size analysis
|
|
444
|
+
return { totalSize: 0, issues: [] };
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
private async analyzeRuntimePerformance(): Promise<{
|
|
448
|
+
averageTime: number;
|
|
449
|
+
issues: Finding[];
|
|
450
|
+
}> {
|
|
451
|
+
// Implementation for runtime performance analysis
|
|
452
|
+
return { averageTime: 0, issues: [] };
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
private async analyzeMemoryUsage(): Promise<{
|
|
456
|
+
peakUsage: number;
|
|
457
|
+
issues: Finding[];
|
|
458
|
+
}> {
|
|
459
|
+
// Implementation for memory usage analysis
|
|
460
|
+
return { peakUsage: 0, issues: [] };
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
private async analyzeProjectStructure(): Promise<{
|
|
464
|
+
violations: Finding[];
|
|
465
|
+
recommendations: any[];
|
|
466
|
+
}> {
|
|
467
|
+
// Implementation for project structure analysis
|
|
468
|
+
return { violations: [], recommendations: [] };
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
private async detectArchitecturalPatterns(): Promise<{
|
|
472
|
+
violations: Finding[];
|
|
473
|
+
recommendations: any[];
|
|
474
|
+
}> {
|
|
475
|
+
// Implementation for architectural pattern detection
|
|
476
|
+
return { violations: [], recommendations: [] };
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
private async findArchitecturalViolations(): Promise<Finding[]> {
|
|
480
|
+
// Implementation for architectural violation detection
|
|
481
|
+
return [];
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
private async performDirectoryScan(
|
|
485
|
+
scanPath: string,
|
|
486
|
+
options: any
|
|
487
|
+
): Promise<Finding[]> {
|
|
488
|
+
// Implementation for directory scanning
|
|
489
|
+
return [];
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
private async autoFixIssues(findings: Finding[]): Promise<number> {
|
|
493
|
+
// Implementation for auto-fixing issues
|
|
494
|
+
let fixedCount = 0;
|
|
495
|
+
|
|
496
|
+
for (const finding of findings) {
|
|
497
|
+
if (finding.fixable && finding.fix) {
|
|
498
|
+
// Apply fix
|
|
499
|
+
fixedCount++;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
return fixedCount;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Output and reporting methods
|
|
508
|
+
*/
|
|
509
|
+
private async outputResults(
|
|
510
|
+
results: AnalysisResult,
|
|
511
|
+
format: string
|
|
512
|
+
): Promise<void> {
|
|
513
|
+
switch (format) {
|
|
514
|
+
case 'json':
|
|
515
|
+
console.log(JSON.stringify(results, null, 2));
|
|
516
|
+
break;
|
|
517
|
+
case 'table':
|
|
518
|
+
this.outputTable(results);
|
|
519
|
+
break;
|
|
520
|
+
case 'graph':
|
|
521
|
+
await this.outputGraph(results);
|
|
522
|
+
break;
|
|
523
|
+
default:
|
|
524
|
+
this.outputTable(results);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
private outputTable(results: AnalysisResult): void {
|
|
529
|
+
if (results.findings.length > 0) {
|
|
530
|
+
console.log(chalk.yellow('\nFindings:'));
|
|
531
|
+
console.table(
|
|
532
|
+
results.findings.map(f => ({
|
|
533
|
+
Severity: f.severity,
|
|
534
|
+
File: f.file,
|
|
535
|
+
Line: f.line || 'N/A',
|
|
536
|
+
Description: f.description,
|
|
537
|
+
Fixable: f.fixable ? '✓' : '✗',
|
|
538
|
+
}))
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
if (Object.keys(results.metrics).length > 0) {
|
|
543
|
+
console.log(chalk.blue('\nMetrics:'));
|
|
544
|
+
console.table(results.metrics);
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
if (results.recommendations.length > 0) {
|
|
548
|
+
console.log(chalk.green('\nRecommendations:'));
|
|
549
|
+
results.recommendations.forEach((rec, i) => {
|
|
550
|
+
console.log(
|
|
551
|
+
`${i + 1}. ${rec.title} (${rec.impact} impact, ${rec.effort} effort)`
|
|
552
|
+
);
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
private async outputGraph(results: AnalysisResult): Promise<void> {
|
|
558
|
+
// Implementation for graph output
|
|
559
|
+
logger.info('Graph visualization not yet implemented');
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
private async generateComprehensiveReport(
|
|
563
|
+
results: AnalysisResult[]
|
|
564
|
+
): Promise<void> {
|
|
565
|
+
// Implementation for comprehensive report generation
|
|
566
|
+
logger.info('Generating comprehensive report...');
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
private async exportResults(
|
|
570
|
+
results: AnalysisResult[],
|
|
571
|
+
exportPath: string
|
|
572
|
+
): Promise<void> {
|
|
573
|
+
await fs.writeJson(exportPath, results, { spaces: 2 });
|
|
574
|
+
logger.success(`Results exported to ${exportPath}`);
|
|
575
|
+
}
|
|
576
|
+
}
|