@@ -5,6 +5,7 @@ import * as httpModule from "http";
55import * as httpsModule from "https" ;
66import * as vscode from "vscode" ;
77import * as Cache from "vscode-cache" ;
8+ import * as semver from "semver" ;
89import {
910 getResolvedConnectionSpec ,
1011 config ,
@@ -18,6 +19,7 @@ import {
1819import { currentWorkspaceFolder , outputChannel , outputConsole } from "../utils" ;
1920
2021const DEFAULT_API_VERSION = 1 ;
22+ const DEFAULT_SERVER_VERSION = "2016.2.0" ;
2123import * as Atelier from "./atelier" ;
2224
2325// Map of the authRequest promises for each username@host :port target to avoid concurrency issues
@@ -27,6 +29,7 @@ export interface ConnectionSettings {
2729 serverName : string ;
2830 active : boolean ;
2931 apiVersion : number ;
32+ serverVersion : string ;
3033 https : boolean ;
3134 host : string ;
3235 port : number ;
@@ -61,12 +64,14 @@ export class AtelierAPI {
6164 const port = this . externalServer ? this . _config . port : workspaceState . get ( wsKey + ":port" , this . _config . port ) ;
6265 const password = workspaceState . get ( wsKey + ":password" , this . _config . password ) ;
6366 const apiVersion = workspaceState . get ( wsKey + ":apiVersion" , DEFAULT_API_VERSION ) ;
67+ const serverVersion = workspaceState . get ( wsKey + ":serverVersion" , DEFAULT_SERVER_VERSION ) ;
6468 const docker = workspaceState . get ( wsKey + ":docker" , false ) ;
6569 const dockerService = workspaceState . get < string > ( wsKey + ":dockerService" ) ;
6670 return {
6771 serverName,
6872 active,
6973 apiVersion,
74+ serverVersion,
7075 https,
7176 host,
7277 port,
@@ -200,6 +205,7 @@ export class AtelierAPI {
200205 serverName,
201206 active : this . externalServer || conn . active ,
202207 apiVersion : workspaceState . get ( this . configName . toLowerCase ( ) + ":apiVersion" , DEFAULT_API_VERSION ) ,
208+ serverVersion : workspaceState . get ( this . configName . toLowerCase ( ) + ":serverVersion" , DEFAULT_SERVER_VERSION ) ,
203209 https : scheme === "https" ,
204210 ns,
205211 host,
@@ -466,6 +472,12 @@ export class AtelierAPI {
466472 if ( info && info . result && info . result . content && info . result . content . api > 0 ) {
467473 const data = info . result . content ;
468474 const apiVersion = data . api ;
475+ const serverVersion = semver . coerce (
476+ data . version
477+ . slice ( data . version . indexOf ( ") " ) + 2 )
478+ . split ( " " )
479+ . shift ( )
480+ ) . version ;
469481 if ( this . ns && this . ns . length && ! data . namespaces . includes ( this . ns ) && checkNs ) {
470482 throw {
471483 code : "WrongNamespace" ,
@@ -476,6 +488,7 @@ export class AtelierAPI {
476488 }
477489 return Promise . all ( [
478490 workspaceState . update ( this . configName . toLowerCase ( ) + ":apiVersion" , apiVersion ) ,
491+ workspaceState . update ( this . configName . toLowerCase ( ) + ":serverVersion" , serverVersion ) ,
479492 workspaceState . update ( this . configName . toLowerCase ( ) + ":iris" , data . version . startsWith ( "IRIS" ) ) ,
480493 ] ) . then ( ( ) => info ) ;
481494 }
0 commit comments