baseguard 1.0.2 ā 1.0.4
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/.baseguardrc.example.json +63 -63
- package/.eslintrc.json +24 -24
- package/.prettierrc +7 -7
- package/CHANGELOG.md +195 -195
- package/DEPLOYMENT.md +624 -624
- package/DEPLOYMENT_CHECKLIST.md +239 -239
- package/DEPLOYMENT_SUMMARY_v1.0.2.md +202 -202
- package/QUICK_START.md +134 -134
- package/README.md +488 -488
- package/RELEASE_NOTES_v1.0.2.md +434 -434
- package/bin/base.js +628 -613
- package/dist/ai/fix-manager.d.ts.map +1 -1
- package/dist/ai/fix-manager.js +1 -1
- package/dist/ai/fix-manager.js.map +1 -1
- package/dist/ai/gemini-analyzer.d.ts.map +1 -1
- package/dist/ai/gemini-analyzer.js +29 -35
- package/dist/ai/gemini-analyzer.js.map +1 -1
- package/dist/ai/gemini-code-fixer.d.ts.map +1 -1
- package/dist/ai/gemini-code-fixer.js +58 -58
- package/dist/ai/gemini-code-fixer.js.map +1 -1
- package/dist/ai/jules-implementer.d.ts +3 -0
- package/dist/ai/jules-implementer.d.ts.map +1 -1
- package/dist/ai/jules-implementer.js +63 -32
- package/dist/ai/jules-implementer.js.map +1 -1
- package/dist/ai/unified-code-fixer.js.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +1 -1
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/config.js +2 -1
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/fix.d.ts.map +1 -1
- package/dist/commands/fix.js +44 -15
- package/dist/commands/fix.js.map +1 -1
- package/dist/core/api-key-manager.js +2 -2
- package/dist/core/api-key-manager.js.map +1 -1
- package/dist/core/baseguard.d.ts +1 -0
- package/dist/core/baseguard.d.ts.map +1 -1
- package/dist/core/baseguard.js +13 -10
- package/dist/core/baseguard.js.map +1 -1
- package/dist/core/baseline-checker.d.ts.map +1 -1
- package/dist/core/baseline-checker.js +2 -1
- package/dist/core/baseline-checker.js.map +1 -1
- package/dist/core/configuration-recovery.d.ts.map +1 -1
- package/dist/core/configuration-recovery.js +1 -1
- package/dist/core/configuration-recovery.js.map +1 -1
- package/dist/core/debug-logger.d.ts.map +1 -1
- package/dist/core/debug-logger.js +1 -1
- package/dist/core/debug-logger.js.map +1 -1
- package/dist/core/error-handler.d.ts.map +1 -1
- package/dist/core/error-handler.js +2 -1
- package/dist/core/error-handler.js.map +1 -1
- package/dist/core/gitignore-manager.js +5 -5
- package/dist/core/graceful-degradation-manager.d.ts.map +1 -1
- package/dist/core/graceful-degradation-manager.js +16 -16
- package/dist/core/graceful-degradation-manager.js.map +1 -1
- package/dist/core/lazy-loader.d.ts.map +1 -1
- package/dist/core/lazy-loader.js +9 -2
- package/dist/core/lazy-loader.js.map +1 -1
- package/dist/core/memory-manager.d.ts +0 -3
- package/dist/core/memory-manager.d.ts.map +1 -1
- package/dist/core/memory-manager.js.map +1 -1
- package/dist/core/parser-worker.d.ts +2 -0
- package/dist/core/parser-worker.d.ts.map +1 -0
- package/dist/core/parser-worker.js +19 -0
- package/dist/core/parser-worker.js.map +1 -0
- package/dist/core/startup-optimizer.d.ts +2 -0
- package/dist/core/startup-optimizer.d.ts.map +1 -1
- package/dist/core/startup-optimizer.js +19 -12
- package/dist/core/startup-optimizer.js.map +1 -1
- package/dist/core/system-error-handler.d.ts.map +1 -1
- package/dist/core/system-error-handler.js +18 -11
- package/dist/core/system-error-handler.js.map +1 -1
- package/dist/git/automation-engine.d.ts.map +1 -1
- package/dist/git/automation-engine.js +5 -4
- package/dist/git/automation-engine.js.map +1 -1
- package/dist/git/github-manager.d.ts.map +1 -1
- package/dist/git/github-manager.js.map +1 -1
- package/dist/git/hook-manager.js +5 -5
- package/dist/git/hook-manager.js.map +1 -1
- package/dist/parsers/parser-manager.d.ts.map +1 -1
- package/dist/parsers/parser-manager.js +1 -1
- package/dist/parsers/parser-manager.js.map +1 -1
- package/dist/parsers/svelte-parser.js +1 -1
- package/dist/parsers/svelte-parser.js.map +1 -1
- package/dist/parsers/vanilla-parser.d.ts.map +1 -1
- package/dist/parsers/vanilla-parser.js.map +1 -1
- package/dist/parsers/vue-parser.d.ts.map +1 -1
- package/dist/parsers/vue-parser.js.map +1 -1
- package/dist/ui/components.d.ts +1 -1
- package/dist/ui/components.d.ts.map +1 -1
- package/dist/ui/components.js +11 -11
- package/dist/ui/components.js.map +1 -1
- package/dist/ui/terminal-header.js +14 -14
- package/package.json +105 -105
- package/src/ai/__tests__/gemini-analyzer.test.ts +180 -180
- package/src/ai/agentkit-orchestrator.ts +533 -533
- package/src/ai/fix-manager.ts +362 -362
- package/src/ai/gemini-analyzer.ts +665 -671
- package/src/ai/gemini-code-fixer.ts +539 -540
- package/src/ai/index.ts +3 -3
- package/src/ai/jules-implementer.ts +504 -460
- package/src/ai/unified-code-fixer.ts +347 -347
- package/src/commands/automation.ts +343 -343
- package/src/commands/check.ts +298 -299
- package/src/commands/config.ts +584 -583
- package/src/commands/fix.ts +264 -238
- package/src/commands/index.ts +6 -6
- package/src/commands/init.ts +155 -155
- package/src/commands/status.ts +306 -306
- package/src/core/api-key-manager.ts +298 -298
- package/src/core/baseguard.ts +757 -756
- package/src/core/baseline-checker.ts +564 -563
- package/src/core/cache-manager.ts +271 -271
- package/src/core/configuration-recovery.ts +672 -673
- package/src/core/configuration.ts +595 -595
- package/src/core/debug-logger.ts +590 -590
- package/src/core/directory-filter.ts +420 -420
- package/src/core/error-handler.ts +518 -517
- package/src/core/file-processor.ts +337 -337
- package/src/core/gitignore-manager.ts +168 -168
- package/src/core/graceful-degradation-manager.ts +596 -596
- package/src/core/index.ts +16 -16
- package/src/core/lazy-loader.ts +317 -307
- package/src/core/memory-manager.ts +290 -295
- package/src/core/parser-worker.ts +33 -0
- package/src/core/startup-optimizer.ts +246 -243
- package/src/core/system-error-handler.ts +755 -750
- package/src/git/automation-engine.ts +361 -361
- package/src/git/github-manager.ts +190 -192
- package/src/git/hook-manager.ts +210 -210
- package/src/git/index.ts +3 -3
- package/src/index.ts +7 -7
- package/src/parsers/feature-validator.ts +558 -558
- package/src/parsers/index.ts +7 -7
- package/src/parsers/parser-manager.ts +418 -419
- package/src/parsers/parser.ts +25 -25
- package/src/parsers/react-parser-optimized.ts +160 -160
- package/src/parsers/react-parser.ts +358 -358
- package/src/parsers/svelte-parser.ts +510 -510
- package/src/parsers/vanilla-parser.ts +685 -686
- package/src/parsers/vue-parser.ts +476 -478
- package/src/types/index.ts +95 -95
- package/src/ui/components.ts +567 -567
- package/src/ui/help.ts +192 -192
- package/src/ui/index.ts +3 -3
- package/src/ui/prompts.ts +680 -680
- package/src/ui/terminal-header.ts +58 -58
- package/test-build.js +40 -40
- package/test-config-commands.js +55 -55
- package/test-header-simple.js +32 -32
- package/test-terminal-header.js +11 -11
- package/test-ui.js +28 -28
- package/tests/e2e/baseguard.e2e.test.ts +515 -515
- package/tests/e2e/cross-platform.e2e.test.ts +419 -419
- package/tests/e2e/git-integration.e2e.test.ts +486 -486
- package/tests/fixtures/react-project/package.json +13 -13
- package/tests/fixtures/react-project/src/App.css +75 -75
- package/tests/fixtures/react-project/src/App.tsx +76 -76
- package/tests/fixtures/svelte-project/package.json +10 -10
- package/tests/fixtures/svelte-project/src/App.svelte +368 -368
- package/tests/fixtures/vanilla-project/index.html +75 -75
- package/tests/fixtures/vanilla-project/script.js +330 -330
- package/tests/fixtures/vanilla-project/styles.css +358 -358
- package/tests/fixtures/vue-project/package.json +11 -11
- package/tests/fixtures/vue-project/src/App.vue +215 -215
- package/tsconfig.json +34 -34
- package/vitest.config.ts +11 -11
- package/dist/terminal-header.d.ts +0 -12
- package/dist/terminal-header.js +0 -45
package/src/commands/check.ts
CHANGED
|
@@ -1,299 +1,298 @@
|
|
|
1
|
-
import { UIComponents } from '../ui/index.js';
|
|
2
|
-
import { BaseGuard } from '../core/baseguard.js';
|
|
3
|
-
import { ConfigurationManager } from '../core/configuration.js';
|
|
4
|
-
import { ConfigurationRecovery } from '../core/configuration-recovery.js';
|
|
5
|
-
import { GracefulDegradationManager } from '../core/graceful-degradation-manager.js';
|
|
6
|
-
import { SystemErrorHandler } from '../core/system-error-handler.js';
|
|
7
|
-
import { ErrorHandler } from '../core/error-handler.js';
|
|
8
|
-
import { logger } from '../core/debug-logger.js';
|
|
9
|
-
import { glob } from 'glob';
|
|
10
|
-
import chalk from 'chalk';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
'
|
|
95
|
-
'
|
|
96
|
-
'
|
|
97
|
-
'.
|
|
98
|
-
'**/*.min.
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
{
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
{
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
console.log(
|
|
189
|
-
console.log(`
|
|
190
|
-
console.log(`
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
{
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
'Run "base
|
|
248
|
-
'
|
|
249
|
-
'
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
'
|
|
256
|
-
'
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
'
|
|
262
|
-
'
|
|
263
|
-
'
|
|
264
|
-
'Use --
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
'Run "base
|
|
279
|
-
'Run
|
|
280
|
-
'
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}
|
|
1
|
+
import { UIComponents } from '../ui/index.js';
|
|
2
|
+
import { BaseGuard } from '../core/baseguard.js';
|
|
3
|
+
import { ConfigurationManager } from '../core/configuration.js';
|
|
4
|
+
import { ConfigurationRecovery } from '../core/configuration-recovery.js';
|
|
5
|
+
import { GracefulDegradationManager } from '../core/graceful-degradation-manager.js';
|
|
6
|
+
import { SystemErrorHandler } from '../core/system-error-handler.js';
|
|
7
|
+
import { ErrorHandler } from '../core/error-handler.js';
|
|
8
|
+
import { logger } from '../core/debug-logger.js';
|
|
9
|
+
import { glob } from 'glob';
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Check for compatibility violations with enhanced error recovery
|
|
14
|
+
*/
|
|
15
|
+
export async function check(options: {
|
|
16
|
+
strict?: boolean;
|
|
17
|
+
files?: string;
|
|
18
|
+
format?: 'table' | 'json' | 'junit';
|
|
19
|
+
debug?: boolean;
|
|
20
|
+
offline?: boolean;
|
|
21
|
+
}): Promise<void> {
|
|
22
|
+
const categoryLogger = logger.createCategoryLogger('check-command');
|
|
23
|
+
logger.startSession('check-command');
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
// Enable debug logging if requested
|
|
27
|
+
if (options.debug) {
|
|
28
|
+
logger.enableDebug();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Set offline mode if requested
|
|
32
|
+
if (options.offline) {
|
|
33
|
+
SystemErrorHandler.setOfflineMode(true);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
UIComponents.showHeader();
|
|
37
|
+
categoryLogger.info('Starting compatibility check', { options });
|
|
38
|
+
|
|
39
|
+
// Load configuration with recovery
|
|
40
|
+
const config = await SystemErrorHandler.withRetry(
|
|
41
|
+
async () => {
|
|
42
|
+
try {
|
|
43
|
+
return await ConfigurationManager.load();
|
|
44
|
+
} catch (error) {
|
|
45
|
+
categoryLogger.warn('Configuration load failed, attempting recovery', { error });
|
|
46
|
+
|
|
47
|
+
// Attempt configuration recovery
|
|
48
|
+
const recoveryResult = await ConfigurationRecovery.recoverConfiguration({
|
|
49
|
+
createBackup: true,
|
|
50
|
+
validateConfig: true,
|
|
51
|
+
migrateVersion: true,
|
|
52
|
+
repairCorruption: true,
|
|
53
|
+
useDefaults: true
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if (recoveryResult.success && recoveryResult.config) {
|
|
57
|
+
if (recoveryResult.warnings.length > 0) {
|
|
58
|
+
console.log(chalk.yellow('ā ļø Configuration was recovered with warnings:'));
|
|
59
|
+
recoveryResult.warnings.forEach(warning => {
|
|
60
|
+
console.log(chalk.yellow(` ⢠${warning}`));
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return recoveryResult.config;
|
|
64
|
+
} else {
|
|
65
|
+
throw new Error(`Configuration recovery failed: ${recoveryResult.errors.join(', ')}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
{ operation: 'load_configuration' },
|
|
70
|
+
2 // max retries
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
// Initialize BaseGuard with error handling
|
|
74
|
+
const baseGuard = await SystemErrorHandler.handleGracefully(
|
|
75
|
+
async () => new BaseGuard(config),
|
|
76
|
+
null,
|
|
77
|
+
{ operation: 'initialize_baseguard' }
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
if (!baseGuard) {
|
|
81
|
+
throw new Error('Failed to initialize BaseGuard');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const spinner = UIComponents.createSpinner('Scanning files for compatibility issues...');
|
|
85
|
+
spinner.start();
|
|
86
|
+
|
|
87
|
+
// Get files to check with error recovery
|
|
88
|
+
const filePattern = options.files || '**/*.{js,jsx,ts,tsx,vue,svelte,css,html}';
|
|
89
|
+
const files = await SystemErrorHandler.handleGracefully(
|
|
90
|
+
async () => {
|
|
91
|
+
return await glob(filePattern, {
|
|
92
|
+
ignore: [
|
|
93
|
+
'node_modules/**',
|
|
94
|
+
'dist/**',
|
|
95
|
+
'build/**',
|
|
96
|
+
'.git/**',
|
|
97
|
+
'**/*.min.js',
|
|
98
|
+
'**/*.min.css'
|
|
99
|
+
]
|
|
100
|
+
});
|
|
101
|
+
},
|
|
102
|
+
[], // fallback to empty array
|
|
103
|
+
{ operation: 'find_files', details: { pattern: filePattern } }
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
if (files.length === 0) {
|
|
107
|
+
spinner.fail('No files found to check');
|
|
108
|
+
|
|
109
|
+
// Show degradation status if in limited mode
|
|
110
|
+
const mode = GracefulDegradationManager.getCurrentMode();
|
|
111
|
+
if (mode && mode.name !== 'Full Functionality') {
|
|
112
|
+
console.log(chalk.yellow(`\nā ļø Currently in ${mode.name} mode`));
|
|
113
|
+
if (mode.limitations.length > 0) {
|
|
114
|
+
console.log(chalk.yellow('Limitations:'));
|
|
115
|
+
mode.limitations.forEach(limitation => {
|
|
116
|
+
console.log(chalk.yellow(` ⢠${limitation}`));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
UIComponents.showWarningBox('No files matched the pattern. Try adjusting the --files option.');
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
spinner.text = `Analyzing ${files.length} files...`;
|
|
126
|
+
categoryLogger.info(`Found ${files.length} files to analyze`);
|
|
127
|
+
|
|
128
|
+
// Scan for violations with enhanced error handling
|
|
129
|
+
const violations = await SystemErrorHandler.handleGracefully(
|
|
130
|
+
async () => {
|
|
131
|
+
return await baseGuard.checkViolations(files);
|
|
132
|
+
},
|
|
133
|
+
[], // fallback to empty violations
|
|
134
|
+
{ operation: 'check_violations', details: { fileCount: files.length } },
|
|
135
|
+
{
|
|
136
|
+
logError: true,
|
|
137
|
+
showWarning: true,
|
|
138
|
+
attemptRecovery: true
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
spinner.stop();
|
|
143
|
+
categoryLogger.info(`Scan completed, found ${violations.length} violations`);
|
|
144
|
+
|
|
145
|
+
// Display results based on format with error handling
|
|
146
|
+
await SystemErrorHandler.handleGracefully(
|
|
147
|
+
async () => {
|
|
148
|
+
switch (options.format) {
|
|
149
|
+
case 'json':
|
|
150
|
+
console.log(JSON.stringify(violations, null, 2));
|
|
151
|
+
break;
|
|
152
|
+
case 'junit':
|
|
153
|
+
UIComponents.showJUnitReport(violations);
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
UIComponents.showViolations(violations);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
undefined,
|
|
161
|
+
{ operation: 'display_results', details: { format: options.format, violationCount: violations.length } },
|
|
162
|
+
{ logError: true, showWarning: false }
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
// Show summary with degradation mode info
|
|
166
|
+
if (violations.length === 0) {
|
|
167
|
+
UIComponents.showSuccessBox('š No compatibility violations found!');
|
|
168
|
+
|
|
169
|
+
// Show mode info if not in full functionality
|
|
170
|
+
const mode = GracefulDegradationManager.getCurrentMode();
|
|
171
|
+
if (mode && mode.name !== 'Full Functionality') {
|
|
172
|
+
console.log(chalk.dim(`\nScan completed in ${mode.name} mode`));
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
const summary = {
|
|
176
|
+
total: violations.length,
|
|
177
|
+
byBrowser: violations.reduce((acc, v) => {
|
|
178
|
+
acc[v.browser] = (acc[v.browser] || 0) + 1;
|
|
179
|
+
return acc;
|
|
180
|
+
}, {} as Record<string, number>),
|
|
181
|
+
byFile: violations.reduce((acc, v) => {
|
|
182
|
+
acc[v.file] = (acc[v.file] || 0) + 1;
|
|
183
|
+
return acc;
|
|
184
|
+
}, {} as Record<string, number>)
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
console.log(chalk.yellow('\nš Summary:'));
|
|
188
|
+
console.log(` Total violations: ${summary.total}`);
|
|
189
|
+
console.log(` Files affected: ${Object.keys(summary.byFile).length}`);
|
|
190
|
+
console.log(` Browsers affected: ${Object.keys(summary.byBrowser).join(', ')}`);
|
|
191
|
+
|
|
192
|
+
// Show appropriate next steps based on current mode
|
|
193
|
+
const mode = GracefulDegradationManager.getCurrentMode();
|
|
194
|
+
if (mode?.capabilities.autoFix) {
|
|
195
|
+
UIComponents.showInfoBox('Run "base fix" to automatically fix these issues with AI assistance.');
|
|
196
|
+
} else {
|
|
197
|
+
UIComponents.showInfoBox('AI fixing is not available in current mode. Review violations manually or restore full functionality.');
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
if (mode && mode.name !== 'Full Functionality') {
|
|
201
|
+
console.log(chalk.dim(`\nScan completed in ${mode.name} mode`));
|
|
202
|
+
if (mode.limitations.length > 0) {
|
|
203
|
+
console.log(chalk.yellow('Current limitations:'));
|
|
204
|
+
mode.limitations.forEach(limitation => {
|
|
205
|
+
console.log(chalk.yellow(` ⢠${limitation}`));
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Create auto-backup if violations found
|
|
212
|
+
if (violations.length > 0) {
|
|
213
|
+
await SystemErrorHandler.handleGracefully(
|
|
214
|
+
async () => {
|
|
215
|
+
const backup = await baseGuard.createConfigBackup();
|
|
216
|
+
if (backup) {
|
|
217
|
+
categoryLogger.debug('Created configuration backup', { backup });
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
undefined,
|
|
221
|
+
{ operation: 'create_backup' },
|
|
222
|
+
{ logError: false, showWarning: false }
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// Exit with error code if violations found and strict mode
|
|
227
|
+
if (options.strict && violations.length > 0) {
|
|
228
|
+
process.exit(1);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
} catch (error) {
|
|
232
|
+
categoryLogger.error('Check command failed', { error });
|
|
233
|
+
|
|
234
|
+
const apiError = ErrorHandler.handleAPIError(error);
|
|
235
|
+
ErrorHandler.displayError(apiError);
|
|
236
|
+
|
|
237
|
+
// Handle service failures gracefully
|
|
238
|
+
if (ErrorHandler.shouldUseFallbackMode(apiError)) {
|
|
239
|
+
await GracefulDegradationManager.handleServiceFailure('check', apiError.type);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Provide specific help for check command issues
|
|
243
|
+
console.log('\nš” Troubleshooting:');
|
|
244
|
+
if (apiError.type === 'configuration') {
|
|
245
|
+
UIComponents.showList([
|
|
246
|
+
'Run "base init" to set up BaseGuard configuration',
|
|
247
|
+
'Run "base config recover" to attempt automatic recovery',
|
|
248
|
+
'Check that .baseguardrc.json exists and is valid',
|
|
249
|
+
'Run "base config validate" to check configuration'
|
|
250
|
+
]);
|
|
251
|
+
} else if (options.files) {
|
|
252
|
+
UIComponents.showList([
|
|
253
|
+
`No files found matching pattern: ${options.files}`,
|
|
254
|
+
'Try a different file pattern (e.g., "src/**/*.ts")',
|
|
255
|
+
'Check that files exist in the specified locations',
|
|
256
|
+
'Use --debug flag for detailed logging'
|
|
257
|
+
]);
|
|
258
|
+
} else {
|
|
259
|
+
UIComponents.showList([
|
|
260
|
+
'Check that you\'re in a project directory',
|
|
261
|
+
'Verify file permissions for reading project files',
|
|
262
|
+
'Try running with a specific file pattern: --files "src/**/*.js"',
|
|
263
|
+
'Use --offline flag if network issues are suspected',
|
|
264
|
+
'Use --debug flag for detailed error information'
|
|
265
|
+
]);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Show fallback suggestions
|
|
269
|
+
if (ErrorHandler.shouldUseFallbackMode(apiError)) {
|
|
270
|
+
console.log('\nš Fallback options:');
|
|
271
|
+
UIComponents.showList(ErrorHandler.getFallbackSuggestions(apiError.type));
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Show recovery options
|
|
275
|
+
console.log('\nš§ Recovery options:');
|
|
276
|
+
UIComponents.showList([
|
|
277
|
+
'Run "base status" to check system health',
|
|
278
|
+
'Run "base config recover" to fix configuration issues',
|
|
279
|
+
'Run with --debug flag to get detailed error information',
|
|
280
|
+
'Check logs in .baseguard/logs/ for more details'
|
|
281
|
+
]);
|
|
282
|
+
|
|
283
|
+
// Generate debug report if in debug mode
|
|
284
|
+
if (options.debug) {
|
|
285
|
+
try {
|
|
286
|
+
const reportFile = await logger.generateDebugReport();
|
|
287
|
+
console.log(chalk.dim(`\nDebug report saved to: ${reportFile}`));
|
|
288
|
+
} catch (reportError) {
|
|
289
|
+
// Ignore report generation errors
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
process.exit(1);
|
|
294
|
+
} finally {
|
|
295
|
+
// End logging session
|
|
296
|
+
await logger.endSession();
|
|
297
|
+
}
|
|
298
|
+
}
|