@@ -9,9 +9,50 @@ import { getExtensionVersion } from "../util/util";
9
9
import { getExtensionUri } from "../util/vscode" ;
10
10
import { VsCodeContinueApi } from "./api" ;
11
11
import { setupInlineTips } from "./inlineTips" ;
12
+ import axios from 'axios' ;
13
+
14
+ const EXTENSION_ID = 'ahrefs.ahrefs-continue' ;
15
+ const CURRENT_VERSION = vscode . extensions . getExtension ( EXTENSION_ID ) ?. packageJSON . version ;
16
+
17
+ async function checkForExtensionUpdate ( ) {
18
+ try {
19
+ const response = await axios . get ( `https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery` , {
20
+ headers : {
21
+ 'Content-Type' : 'application/json' ,
22
+ 'Accept' : 'application/json;api-version=3.0-preview.1'
23
+ } ,
24
+ data : {
25
+ filters : [ {
26
+ criteria : [ { filterType : 7 , value : EXTENSION_ID } ]
27
+ } ] ,
28
+ flags : 131
29
+ }
30
+ } ) ;
31
+
32
+ const latestVersion = response . data . results [ 0 ] . extensions [ 0 ] . versions [ 0 ] . version ;
33
+
34
+ if ( latestVersion !== CURRENT_VERSION ) {
35
+ notifyUpdateAvailable ( latestVersion ) ;
36
+ }
37
+ } catch ( error ) {
38
+ console . error ( 'Failed to check for updates:' , error ) ;
39
+ }
40
+ }
41
+
42
+ function notifyUpdateAvailable ( latestVersion : string ) {
43
+ const message = `A new version (${ latestVersion } ) of Ahrefs-Continue is available!` ;
44
+ const updateAction = 'Update Now' ;
45
+
46
+ vscode . window . showInformationMessage ( message , updateAction ) . then ( selection => {
47
+ if ( selection === updateAction ) {
48
+ vscode . commands . executeCommand ( 'extension.open' , EXTENSION_ID ) ;
49
+ }
50
+ } ) ;
51
+ }
12
52
13
53
export async function activateExtension ( context : vscode . ExtensionContext ) {
14
54
// Add necessary files
55
+ checkForExtensionUpdate ( ) ;
15
56
getTsConfigPath ( ) ;
16
57
getContinueRcPath ( ) ;
17
58
0 commit comments