import { commands , extensions , window } from 'vscode' ; import axios from 'axios' ; const compareVersions = require ( 'compare-versions' ) ; export const checkForUpdate = ( ) => { const consoleHelperExt = extensions . getExtension ( 'at-9420.console-helper' ) ; const version = consoleHelperExt ?. packageJSON ?. version ; axios . get ( 'https://api.github.com/repos/shangZhengXie/vscode-console-helper/tags' ) . then ( res => { const [ newTag ] = res . data ; const latestVersion = newTag . name ; if ( compareVersions ( version , latestVersion ) === - 1 ) { window . showInformationMessage ( '检查到 [ console helper ] 插件有新版本，是否立即升级？' , '去升级' , '取消' ) . then ( res => { if ( res === '去升级' ) { commands . executeCommand ( 'workbench.extensions.action.showInstalledExtensions' ) ; } } ) ; } } ) ; } ;