Skip to content

Commit cf919ff

Browse files
authored
Add beta support for schema check. Closes #73 (#74)
1 parent 87e640c commit cf919ff

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/codeactions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export const registerCodeActions = (context: vscode.ExtensionContext) => {
66
if (!devProxyInstall) {
77
return;
88
}
9+
const devProxyVersion = devProxyInstall.isBeta ? devProxyInstall.version.split('-')[0] : devProxyInstall.version;
910
context.subscriptions.push(
1011
vscode.languages.registerCodeActionsProvider('json', {
1112
provideCodeActions: (document, range, context, token) => {
@@ -21,7 +22,7 @@ export const registerCodeActions = (context: vscode.ExtensionContext) => {
2122
diagnostic.range.start,
2223
diagnostic.range.end
2324
),
24-
`$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v${devProxyInstall.version}/rc.schema.json",`
25+
`$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v${devProxyVersion}/rc.schema.json",`
2526
);
2627
return [fix];
2728
}

src/diagnostics.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@ export const updateDiagnostics = (
2020
const schemaNode = getASTNode(documentNode.children, 'Identifier', '$schema');
2121
if (schemaNode) {
2222
const schemaValue = (schemaNode.value as parse.LiteralNode).value as string;
23-
if (!schemaValue.includes(`${devProxyInstall.version}`)) {
23+
const devProxyVersion = devProxyInstall.isBeta ? devProxyInstall.version.split('-')[0] : devProxyInstall.version;
24+
if (!schemaValue.includes(`${devProxyVersion}`)) {
2425
const diagnostic = new vscode.Diagnostic(
2526
getRangeFromASTNode(schemaNode),
26-
`Schema version is not compatible with the installed version of Dev Proxy. Expected v${devProxyInstall.version}.`,
27+
`Schema version is not compatible with the installed version of Dev Proxy. Expected v${devProxyVersion}`,
2728
vscode.DiagnosticSeverity.Warning
2829
);
2930
diagnostic.code = 'invalidSchema';

src/test/extension.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ suite('schema', () => {
548548
const diagnostics = vscode.languages.getDiagnostics(document.uri);
549549

550550
const expected = {
551-
message: 'Schema version is not compatible with the installed version of Dev Proxy. Expected v0.1.0.',
551+
message: 'Schema version is not compatible with the installed version of Dev Proxy. Expected v0.1.0',
552552
severity: vscode.DiagnosticSeverity.Warning,
553553
};
554554
const actual = {

0 commit comments

Comments
 (0)