deflake 1.1.0 → 1.1.2

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.
Files changed (2) hide show
  1. package/cli.js +32 -21
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -7,13 +7,29 @@ const fs = require('fs');
7
7
  const path = require('path');
8
8
  const pkg = require('./package.json');
9
9
 
10
+ // --- COLORS ---
11
+ const C = {
12
+ RESET: "\x1b[0m",
13
+ BRIGHT: "\x1b[1m",
14
+ RED: "\x1b[31m",
15
+ GREEN: "\x1b[32m",
16
+ YELLOW: "\x1b[33m",
17
+ CYAN: "\x1b[36m",
18
+ BLUE: "\x1b[34m",
19
+ GRAY: "\x1b[90m",
20
+ WHITE: "\x1b[37m"
21
+ };
22
+
10
23
  // --- DETERMINISTIC COMMAND INTERCEPTION ---
11
24
  // Check for diagnostic commands before yargs or main logic even starts
12
25
  const rawArgs = process.argv.slice(2);
13
26
  if (rawArgs.includes('doctor') || rawArgs.includes('--doctor')) {
14
27
  // We run the doctor logic and force exit to prevent any wrapper loops
15
28
  const doctorArgv = yargs(hideBin(process.argv)).argv;
16
- runDoctor(doctorArgv).then(() => process.exit(0)).catch(() => process.exit(1));
29
+ runDoctor(doctorArgv).then(() => process.exit(0)).catch((err) => {
30
+ console.error(`${C.RED}Doctor failed:${C.RESET} ${err.message}`);
31
+ process.exit(1);
32
+ });
17
33
  return; // Safety for some environments
18
34
  }
19
35
  // ------------------------------------------
@@ -346,18 +362,7 @@ function extractFailureLocation(logText) {
346
362
  return null;
347
363
  }
348
364
 
349
- // --- COLORS ---
350
- const C = {
351
- RESET: "\x1b[0m",
352
- BRIGHT: "\x1b[1m",
353
- RED: "\x1b[31m",
354
- GREEN: "\x1b[32m",
355
- YELLOW: "\x1b[33m",
356
- CYAN: "\x1b[36m",
357
- BLUE: "\x1b[34m",
358
- GRAY: "\x1b[90m",
359
- WHITE: "\x1b[37m"
360
- };
365
+ // --- COLORS Moved to top ---
361
366
 
362
367
  function printDetailedFix(fixText, location, sourceCode = null, isApplied = false) {
363
368
 
@@ -505,11 +510,11 @@ async function runDoctor(argv) {
505
510
 
506
511
  // 2. Framework Detection
507
512
  console.log(`${C.BRIGHT}Detecting Frameworks:${C.RESET}`);
508
- const framework = DeFlakeClient.detectFramework();
513
+ const activeFramework = DeFlakeClient.detectFramework();
509
514
 
510
- if (framework !== 'generic') {
511
- const capitalized = framework.charAt(0).toUpperCase() + framework.slice(1);
512
- console.log(` ✅ Found: ${C.GREEN}${capitalized}${C.RESET}`);
515
+ if (activeFramework !== 'generic') {
516
+ const capitalized = activeFramework.charAt(0).toUpperCase() + activeFramework.slice(1);
517
+ console.log(` ✅ Active: ${C.GREEN}${C.BRIGHT}${capitalized}${C.RESET}`);
513
518
  } else {
514
519
  console.log(` ⚠️ ${C.YELLOW}No supported frameworks detected in the current directory.${C.RESET}`);
515
520
  console.log(` (Checked for Playwright, Cypress, WebdriverIO files)`);
@@ -541,12 +546,18 @@ async function runDoctor(argv) {
541
546
  const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
542
547
  const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
543
548
  const detectedDeps = [];
544
- if (deps['@playwright/test']) detectedDeps.push('@playwright/test');
545
- if (deps['cypress']) detectedDeps.push('cypress');
546
- if (deps['webdriverio']) detectedDeps.push('webdriverio');
549
+
550
+ // Core frameworks
551
+ if (deps['@playwright/test']) detectedDeps.push(`${C.CYAN}@playwright/test${C.RESET}`);
552
+ if (deps['cypress']) detectedDeps.push(`${C.CYAN}cypress${C.RESET}`);
553
+ if (deps['webdriverio'] || deps['@wdio/cli']) detectedDeps.push(`${C.CYAN}webdriverio${C.RESET}`);
554
+
555
+ // Common plugins
556
+ if (deps['dotenv']) detectedDeps.push('dotenv');
557
+ if (deps['typescript']) detectedDeps.push('typescript');
547
558
 
548
559
  if (detectedDeps.length > 0) {
549
- console.log(` Installed: ${C.GREEN}${detectedDeps.join(', ')}${C.RESET}`);
560
+ console.log(` 📦 Installed: ${detectedDeps.join(', ')}`);
550
561
  }
551
562
  } catch (e) {
552
563
  console.log(` ❌ ${C.RED}Error reading package.json${C.RESET}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deflake",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "AI-powered self-healing tool for Playwright, Cypress, and WebdriverIO tests.",
5
5
  "main": "client.js",
6
6
  "bin": {