@@ -7,34 +7,38 @@ import * as fs from 'fs';
7
7
import * as path from 'path' ;
8
8
import { fileURLToPath } from 'url' ;
9
9
10
- const fallbackVersion = '^1.54 .0' ;
10
+ const fallbackVersion = '^1.103 .0' ;
11
11
let versionPromise = undefined ;
12
12
13
13
export function getLatestVSCodeVersion ( ) {
14
14
if ( ! versionPromise ) {
15
- versionPromise = request . xhr ( { url : 'https://update.code.visualstudio.com/api/releases/stable' , headers : { "X-API-Version" : "2" } } ) . then ( res => {
16
- if ( res . status === 200 ) {
17
- try {
18
- var tagsAndCommits = JSON . parse ( res . responseText ) ;
19
- if ( Array . isArray ( tagsAndCommits ) && tagsAndCommits . length > 0 ) {
20
- var segments = tagsAndCommits [ 0 ] . version . split ( '.' ) ;
21
- if ( segments . length === 3 ) {
22
- return '^' + segments [ 0 ] + '.' + segments [ 1 ] + '.0' ;
15
+ // Fetch the latest published @types /vscode version from the npm registry
16
+ // and return a caret-pinned range (e.g. ^1.93.0).
17
+ versionPromise = request
18
+ . xhr ( { url : 'https://registry.npmjs.org/@types/vscode/latest' , headers : { 'Accept' : 'application/json' } } )
19
+ . then (
20
+ res => {
21
+ if ( res . status === 200 ) {
22
+ try {
23
+ const meta = JSON . parse ( res . responseText ) ;
24
+ if ( meta && typeof meta . version === 'string' && meta . version ) {
25
+ return '^' + meta . version ;
26
+ }
27
+ } catch ( e ) {
28
+ console . log ( 'Problem parsing @types/vscode metadata: ' + res . responseText , e ) ;
23
29
}
30
+ } else {
31
+ console . warn ( 'Unable to evaluate the latest @types/vscode version: Status code: ' + res . status + ', ' + res . responseText ) ;
24
32
}
25
- } catch ( e ) {
26
- console . log ( 'Problem parsing version: ' + res . responseText , e ) ;
33
+ console . warn ( 'Falling back to: ' + fallbackVersion ) ;
34
+ return fallbackVersion ;
35
+ } ,
36
+ err => {
37
+ console . warn ( 'Unable to evaluate the latest @types/vscode version: Error: ' , err ) ;
38
+ console . warn ( 'Falling back to: ' + fallbackVersion ) ;
39
+ return fallbackVersion ;
27
40
}
28
- } else {
29
- console . warn ( 'Unable to evaluate the latest vscode version: Status code: ' + res . status + ', ' + res . responseText ) ;
30
- }
31
- console . warn ( 'Falling back to: ' + fallbackVersion ) ;
32
- return fallbackVersion ;
33
- } , err => {
34
- console . warn ( 'Unable to evaluate the latest vscode version: Error: ' , err ) ;
35
- console . warn ( 'Falling back to: ' + fallbackVersion ) ;
36
- return fallbackVersion ;
37
- } ) ;
41
+ ) ;
38
42
}
39
43
return versionPromise ;
40
44
} ;
0 commit comments