Skip to content

Commit 76e9bac

Browse files
committed
Fix new version notification. Closes #281
Closes #281
1 parent 5ff22fd commit 76e9bac

File tree

3 files changed

+96
-3
lines changed

3 files changed

+96
-3
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
> **Note**: odd version numbers, for example, `0.13.0`, are not included in this changelog. They are used to test the new features and fixes before the final release.
99
10-
## [0.25.3] - Unreleased
10+
## [0.25.4] - Unreleased
1111

1212
### Added:
1313

@@ -24,6 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424
- Improved diagnostics range detection to ensure that they only appear againt the relevant code and don't overlap with ending quotes and commas
2525
- Detection: Changed isDevProxyRunning check to use Dev Proxy API instead of process detection
2626

27+
### Fixed:
28+
29+
- Detection: Improved new version detection logic to resolve issue where toast notification would output irrelevant information
30+
2731
## [0.24.0] - 2025-06-04
2832

2933
### Added:

src/detect.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export const detectDevProxyInstall = async (versionPreference: VersionPreference
2525
const isOutdated = isInstalled && outdatedVersion !== '';
2626
const isRunning = await isDevProxyRunning(devProxyExe);
2727
vscode.commands.executeCommand('setContext', 'isDevProxyRunning', isRunning);
28-
2928
return {
3029
version,
3130
isInstalled,
@@ -37,10 +36,22 @@ export const detectDevProxyInstall = async (versionPreference: VersionPreference
3736
};
3837
};
3938

39+
export const extractVersionFromOutput = (output: string): string => {
40+
if (!output) {
41+
return '';
42+
}
43+
44+
// Extract version number using semver pattern
45+
// Matches: major.minor.patch[-prerelease][+build] but only captures up to prerelease
46+
const semverRegex = /v?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9.-]+)?)(?:\+[a-zA-Z0-9.-]+)?/;
47+
const match = output.match(semverRegex);
48+
return match ? match[1] : '';
49+
};
50+
4051
export const getOutdatedVersion = async (devProxyExe: string): Promise<string> => {
4152
try {
4253
const outdated = await executeCommand(`${devProxyExe} outdated --short`);
43-
return outdated ? outdated.trim() : '';
54+
return extractVersionFromOutput(outdated);
4455
} catch (error) {
4556
return "";
4657
}

src/test/extension.test.ts

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,3 +548,81 @@ suite('Commands', () => {
548548
assert.ok(jwtCreateCommand, 'JWT create command should be registered');
549549
});
550550
});
551+
552+
suite('extractVersionFromOutput', () => {
553+
test('should extract stable version from Dev Proxy output', () => {
554+
const output = ` info 1 error responses loaded from /opt/homebrew/Cellar/dev-proxy/0.29.0/devproxy-errors.json
555+
info v0.29.0`;
556+
557+
const result = detect.extractVersionFromOutput(output);
558+
assert.strictEqual(result, '0.29.0');
559+
});
560+
561+
test('should extract beta version from Dev Proxy output', () => {
562+
const output = ` info 1 error responses loaded from /opt/homebrew/Cellar/dev-proxy/0.30.0-beta.1/devproxy-errors.json
563+
info v0.30.0-beta.1`;
564+
565+
const result = detect.extractVersionFromOutput(output);
566+
assert.strictEqual(result, '0.30.0-beta.1');
567+
});
568+
569+
test('should extract version without v prefix', () => {
570+
const output = ` info Some message
571+
info 1.2.3`;
572+
573+
const result = detect.extractVersionFromOutput(output);
574+
assert.strictEqual(result, '1.2.3');
575+
});
576+
577+
test('should extract pre-release version with alpha identifier', () => {
578+
const output = ` info Dev Proxy version
579+
info v2.1.0-alpha.5`;
580+
581+
const result = detect.extractVersionFromOutput(output);
582+
assert.strictEqual(result, '2.1.0-alpha.5');
583+
});
584+
585+
test('should extract pre-release version with rc identifier', () => {
586+
const output = ` info Dev Proxy version
587+
info v1.5.0-rc.2`;
588+
589+
const result = detect.extractVersionFromOutput(output);
590+
assert.strictEqual(result, '1.5.0-rc.2');
591+
});
592+
593+
test('should return empty string for output without version', () => {
594+
const output = ` info Some random output
595+
info No version here`;
596+
597+
const result = detect.extractVersionFromOutput(output);
598+
assert.strictEqual(result, '');
599+
});
600+
601+
test('should return empty string for empty output', () => {
602+
const result = detect.extractVersionFromOutput('');
603+
assert.strictEqual(result, '');
604+
});
605+
606+
test('should return empty string for null/undefined output', () => {
607+
const result1 = detect.extractVersionFromOutput(null as any);
608+
const result2 = detect.extractVersionFromOutput(undefined as any);
609+
assert.strictEqual(result1, '');
610+
assert.strictEqual(result2, '');
611+
});
612+
613+
test('should extract first version when multiple versions present', () => {
614+
const output = ` info v1.0.0
615+
info v2.0.0`;
616+
617+
const result = detect.extractVersionFromOutput(output);
618+
assert.strictEqual(result, '1.0.0');
619+
});
620+
621+
test('should handle version with build metadata', () => {
622+
const output = ` info Build info
623+
info v1.0.0-beta.1+build.123`;
624+
625+
const result = detect.extractVersionFromOutput(output);
626+
assert.strictEqual(result, '1.0.0-beta.1');
627+
});
628+
});

0 commit comments

Comments
 (0)