deflake 1.0.4 → 1.0.6
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/cli.js +38 -2
- package/client.js +4 -4
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -272,7 +272,8 @@ function extractFailureLocation(logText) {
|
|
|
272
272
|
stepLine: null
|
|
273
273
|
};
|
|
274
274
|
|
|
275
|
-
|
|
275
|
+
// Updated regex to be more flexible with arrows and spaces
|
|
276
|
+
const testMatch = logText.match(/^\s*\d+\)\s+\[.*?\]\s+.+?\s+(.*?.spec.ts):(\d+):(\d+)/m);
|
|
276
277
|
if (testMatch) {
|
|
277
278
|
loc.specFile = testMatch[1];
|
|
278
279
|
loc.testLine = testMatch[2];
|
|
@@ -377,9 +378,44 @@ async function runDoctor(argv) {
|
|
|
377
378
|
|
|
378
379
|
console.log(`\n${C.BRIGHT}👨⚕️ DeFlake Doctor - Diagnostic Tool${C.RESET}\n`);
|
|
379
380
|
|
|
380
|
-
// 1. Environment Info
|
|
381
|
+
// 1. Environment Info & Version Check
|
|
381
382
|
console.log(`${C.BRIGHT}Checking Environment:${C.RESET}`);
|
|
382
383
|
console.log(` - DeFlake version: ${C.CYAN}${pkg.version}${C.RESET}`);
|
|
384
|
+
|
|
385
|
+
// Check for updates from npm
|
|
386
|
+
try {
|
|
387
|
+
const https = require('https');
|
|
388
|
+
const latestVersion = await new Promise((resolve, reject) => {
|
|
389
|
+
const req = https.get('https://registry.npmjs.org/deflake/latest', { timeout: 3000 }, (res) => {
|
|
390
|
+
let data = '';
|
|
391
|
+
res.on('data', chunk => data += chunk);
|
|
392
|
+
res.on('end', () => {
|
|
393
|
+
try {
|
|
394
|
+
resolve(JSON.parse(data).version);
|
|
395
|
+
} catch (e) { resolve(null); }
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
req.on('error', () => resolve(null));
|
|
399
|
+
req.on('timeout', () => { req.destroy(); resolve(null); });
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
if (latestVersion && latestVersion !== pkg.version) {
|
|
403
|
+
// Compare versions
|
|
404
|
+
const current = pkg.version.split('.').map(Number);
|
|
405
|
+
const latest = latestVersion.split('.').map(Number);
|
|
406
|
+
const isOutdated = latest[0] > current[0] ||
|
|
407
|
+
(latest[0] === current[0] && latest[1] > current[1]) ||
|
|
408
|
+
(latest[0] === current[0] && latest[1] === current[1] && latest[2] > current[2]);
|
|
409
|
+
|
|
410
|
+
if (isOutdated) {
|
|
411
|
+
console.log(` ⚠️ ${C.YELLOW}Update available: ${pkg.version} → ${latestVersion}${C.RESET}`);
|
|
412
|
+
console.log(` ${C.GREEN}Run: npx deflake@${latestVersion} doctor${C.RESET}`);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
} catch (e) {
|
|
416
|
+
// Silent failure - version check is optional
|
|
417
|
+
}
|
|
418
|
+
|
|
383
419
|
console.log(` - Node.js version: ${C.CYAN}${process.version}${C.RESET}`);
|
|
384
420
|
console.log(` - Platform: ${C.CYAN}${process.platform}${C.RESET}\n`);
|
|
385
421
|
|
package/client.js
CHANGED
|
@@ -69,10 +69,10 @@ class DeFlakeClient {
|
|
|
69
69
|
const htmlContent = fs.readFileSync(htmlPath, 'utf8');
|
|
70
70
|
|
|
71
71
|
const payload = {
|
|
72
|
-
error_log: logContent,
|
|
73
|
-
html_snapshot: htmlContent,
|
|
74
|
-
failing_line: failureLocation ? `Line ${failureLocation.rootLine}` :
|
|
75
|
-
source_code: sourceCode
|
|
72
|
+
error_log: logContent || "",
|
|
73
|
+
html_snapshot: htmlContent || "",
|
|
74
|
+
failing_line: failureLocation ? `Line ${failureLocation.rootLine}` : "",
|
|
75
|
+
source_code: sourceCode || ""
|
|
76
76
|
};
|
|
77
77
|
|
|
78
78
|
const response = await axios.post(this.apiUrl, payload, {
|