@@ -5,6 +5,7 @@ import * as httpModule from "http";
5
5
import * as httpsModule from "https" ;
6
6
import * as vscode from "vscode" ;
7
7
import * as Cache from "vscode-cache" ;
8
+ import * as semver from "semver" ;
8
9
import {
9
10
getResolvedConnectionSpec ,
10
11
config ,
@@ -18,6 +19,7 @@ import {
18
19
import { currentWorkspaceFolder , outputChannel , outputConsole } from "../utils" ;
19
20
20
21
const DEFAULT_API_VERSION = 1 ;
22
+ const DEFAULT_SERVER_VERSION = "2016.2.0" ;
21
23
import * as Atelier from "./atelier" ;
22
24
23
25
// Map of the authRequest promises for each username@host :port target to avoid concurrency issues
@@ -27,6 +29,7 @@ export interface ConnectionSettings {
27
29
serverName : string ;
28
30
active : boolean ;
29
31
apiVersion : number ;
32
+ serverVersion : string ;
30
33
https : boolean ;
31
34
host : string ;
32
35
port : number ;
@@ -61,12 +64,14 @@ export class AtelierAPI {
61
64
const port = this . externalServer ? this . _config . port : workspaceState . get ( wsKey + ":port" , this . _config . port ) ;
62
65
const password = workspaceState . get ( wsKey + ":password" , this . _config . password ) ;
63
66
const apiVersion = workspaceState . get ( wsKey + ":apiVersion" , DEFAULT_API_VERSION ) ;
67
+ const serverVersion = workspaceState . get ( wsKey + ":serverVersion" , DEFAULT_SERVER_VERSION ) ;
64
68
const docker = workspaceState . get ( wsKey + ":docker" , false ) ;
65
69
const dockerService = workspaceState . get < string > ( wsKey + ":dockerService" ) ;
66
70
return {
67
71
serverName,
68
72
active,
69
73
apiVersion,
74
+ serverVersion,
70
75
https,
71
76
host,
72
77
port,
@@ -200,6 +205,7 @@ export class AtelierAPI {
200
205
serverName,
201
206
active : this . externalServer || conn . active ,
202
207
apiVersion : workspaceState . get ( this . configName . toLowerCase ( ) + ":apiVersion" , DEFAULT_API_VERSION ) ,
208
+ serverVersion : workspaceState . get ( this . configName . toLowerCase ( ) + ":serverVersion" , DEFAULT_SERVER_VERSION ) ,
203
209
https : scheme === "https" ,
204
210
ns,
205
211
host,
@@ -466,6 +472,12 @@ export class AtelierAPI {
466
472
if ( info && info . result && info . result . content && info . result . content . api > 0 ) {
467
473
const data = info . result . content ;
468
474
const apiVersion = data . api ;
475
+ const serverVersion = semver . coerce (
476
+ data . version
477
+ . slice ( data . version . indexOf ( ") " ) + 2 )
478
+ . split ( " " )
479
+ . shift ( )
480
+ ) . version ;
469
481
if ( this . ns && this . ns . length && ! data . namespaces . includes ( this . ns ) && checkNs ) {
470
482
throw {
471
483
code : "WrongNamespace" ,
@@ -476,6 +488,7 @@ export class AtelierAPI {
476
488
}
477
489
return Promise . all ( [
478
490
workspaceState . update ( this . configName . toLowerCase ( ) + ":apiVersion" , apiVersion ) ,
491
+ workspaceState . update ( this . configName . toLowerCase ( ) + ":serverVersion" , serverVersion ) ,
479
492
workspaceState . update ( this . configName . toLowerCase ( ) + ":iris" , data . version . startsWith ( "IRIS" ) ) ,
480
493
] ) . then ( ( ) => info ) ;
481
494
}
0 commit comments