|
6 | 6 | import * as _ from 'lodash'
|
7 | 7 | import * as path from 'path'
|
8 | 8 | import * as vscode from 'vscode'
|
| 9 | +import * as semver from 'semver' |
9 | 10 | import * as nls from 'vscode-nls'
|
10 | 11 |
|
11 | 12 | import { BaseTemplates } from './templates/baseTemplates'
|
12 | 13 | import { fs } from '../shared/fs/fs'
|
13 |
| -import { getIdeProperties, isCloud9, isCn } from './extensionUtilities' |
| 14 | +import { getIdeProperties, getIdeType, isAmazonQ, isCloud9, isCn, productName } from './extensionUtilities' |
| 15 | +import * as localizedText from './localizedText' |
| 16 | +import { AmazonQPromptSettings, ToolkitPromptSettings } from './settings' |
14 | 17 |
|
15 | 18 | const localize = nls.loadMessageBundle()
|
16 | 19 |
|
| 20 | +/** |
| 21 | + * Shows a (suppressible) warning if the current vscode version is older than `minVscode`. |
| 22 | + */ |
| 23 | +export async function maybeShowMinVscodeWarning(minVscode: string) { |
| 24 | + const settings = isAmazonQ() ? AmazonQPromptSettings.instance : ToolkitPromptSettings.instance |
| 25 | + if (!(await settings.isPromptEnabled('minIdeVersion'))) { |
| 26 | + return |
| 27 | + } |
| 28 | + const updateButton = `Update ${vscode.env.appName}` |
| 29 | + if (getIdeType() === 'vscode' && semver.lt(vscode.version, minVscode)) { |
| 30 | + void vscode.window |
| 31 | + .showWarningMessage( |
| 32 | + `${productName()} will soon require VS Code ${minVscode} or newer. The currently running version ${vscode.version} will no longer receive updates.`, |
| 33 | + updateButton, |
| 34 | + localizedText.dontShow |
| 35 | + ) |
| 36 | + .then(async (resp) => { |
| 37 | + if (resp === updateButton) { |
| 38 | + await vscode.commands.executeCommand('update.checkForUpdate') |
| 39 | + } else if (resp === localizedText.dontShow) { |
| 40 | + void settings.disablePrompt('minIdeVersion') |
| 41 | + } |
| 42 | + }) |
| 43 | + } |
| 44 | +} |
| 45 | + |
17 | 46 | /**
|
18 | 47 | * Helper function to show a webview containing the quick start page
|
19 | 48 | *
|
|
0 commit comments