Skip to content

Commit 699919d

Browse files
authored
Merge #5749 from justinmk3/minvscode
feat(startup): show message if vscode is outdated
2 parents adccdd4 + e20a8de commit 699919d

16 files changed

+88
-24
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Deprecation",
3+
"description": "The next release of this extension will require VS Code 1.83.0 or newer."
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Feature",
3+
"description": "Show a one-time warning if new VS Code is required"
4+
}

packages/amazonq/package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,10 @@
112112
"type": "boolean",
113113
"default": false
114114
},
115+
"minIdeVersion": {
116+
"type": "boolean",
117+
"default": false
118+
},
115119
"ssoCacheError": {
116120
"type": "boolean",
117121
"default": false
@@ -1046,6 +1050,6 @@
10461050
},
10471051
"engines": {
10481052
"npm": "^10.1.0",
1049-
"vscode": "^1.83.0"
1053+
"vscode": "^1.68.0"
10501054
}
10511055
}

packages/amazonq/src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
placeholder,
4141
setContext,
4242
setupUninstallHandler,
43+
maybeShowMinVscodeWarning,
4344
} from 'aws-core-vscode/shared'
4445
import { ExtStartUpSources, telemetry } from 'aws-core-vscode/telemetry'
4546
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
@@ -98,6 +99,8 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
9899
}
99100
}
100101

102+
void maybeShowMinVscodeWarning('1.83.0')
103+
101104
globals.machineId = await getMachineId()
102105
globals.awsContext = new DefaultAwsContext()
103106
globals.sdkClientBuilder = new DefaultAWSClientBuilder(globals.awsContext)

packages/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": "Apache-2.0",
66
"engines": {
77
"npm": "^10.1.0",
8-
"vscode": "^1.83.0"
8+
"vscode": "^1.68.0"
99
},
1010
"exports": {
1111
".": "./dist/src/extension.js",

packages/core/src/extension.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ import { registerCommands } from './commands'
5555
// In web mode everything must be in a single file, so things like the endpoints file will not be available.
5656
// The following imports the endpoints file, which causes webpack to bundle it in the final output file
5757
import endpoints from '../resources/endpoints.json'
58-
import { getLogger, setupUninstallHandler } from './shared'
58+
import { getLogger, maybeShowMinVscodeWarning, setupUninstallHandler } from './shared'
5959
import { showViewLogsMessage } from './shared/utilities/messages'
6060

6161
disableAwsSdkWarning()
@@ -102,6 +102,8 @@ export async function activateCommon(
102102
getLogger().error('fs.init: invalid home directory given by env vars: %O', homeDirLogs)
103103
}
104104

105+
void maybeShowMinVscodeWarning('1.83.0')
106+
105107
if (isCloud9()) {
106108
vscode.window.withProgress = wrapWithProgressForCloud9(globals.outputChannel)
107109
context.subscriptions.push(

packages/core/src/shared/extensionStartup.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,43 @@
66
import * as _ from 'lodash'
77
import * as path from 'path'
88
import * as vscode from 'vscode'
9+
import * as semver from 'semver'
910
import * as nls from 'vscode-nls'
1011

1112
import { BaseTemplates } from './templates/baseTemplates'
1213
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'
1417

1518
const localize = nls.loadMessageBundle()
1619

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+
1746
/**
1847
* Helper function to show a webview containing the quick start page
1948
*

packages/core/src/shared/extensionUtilities.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,36 +58,29 @@ export function commandsPrefix(): string {
5858
return isAmazonQ() ? 'Amazon Q' : getIdeProperties().company
5959
}
6060

61-
export enum IDE {
62-
vscode,
63-
cloud9,
64-
sagemaker,
65-
unknown,
66-
}
67-
6861
let computeRegion: string | undefined = notInitialized
6962

70-
export function getIdeType(): IDE {
63+
export function getIdeType(): 'vscode' | 'cloud9' | 'sagemaker' | 'unknown' {
7164
const settings = DevSettings.instance
7265
if (
7366
vscode.env.appName === cloud9Appname ||
7467
vscode.env.appName === cloud9CnAppname ||
7568
settings.get('forceCloud9', false)
7669
) {
77-
return IDE.cloud9
70+
return 'cloud9'
7871
}
7972

8073
if (vscode.env.appName === sageMakerAppname) {
81-
return IDE.sagemaker
74+
return 'sagemaker'
8275
}
8376

8477
// Theia doesn't necessarily have all env properties
8578
// so we should be defensive and assume appName is nullable.
8679
if (vscode.env.appName?.startsWith(vscodeAppname)) {
87-
return IDE.vscode
80+
return 'vscode'
8881
}
8982

90-
return IDE.unknown
83+
return 'unknown'
9184
}
9285

9386
interface IdeProperties {
@@ -112,12 +105,12 @@ export function getIdeProperties(): IdeProperties {
112105
}
113106

114107
switch (getIdeType()) {
115-
case IDE.cloud9:
108+
case 'cloud9':
116109
if (isCn()) {
117110
return createCloud9Properties(localize('AWS.title.cn', 'Amazon'))
118111
}
119112
return createCloud9Properties(company)
120-
case IDE.sagemaker:
113+
case 'sagemaker':
121114
if (isCn()) {
122115
// check for cn region
123116
return createSageMakerProperties(localize('AWS.title.cn', 'Amazon'))
@@ -155,7 +148,7 @@ function createCloud9Properties(company: string): IdeProperties {
155148
* Decides if the current system is (the specified flavor of) Cloud9.
156149
*/
157150
export function isCloud9(flavor: 'classic' | 'codecatalyst' | 'any' = 'any'): boolean {
158-
const cloud9 = getIdeType() === IDE.cloud9
151+
const cloud9 = getIdeType() === 'cloud9'
159152
if (!cloud9 || flavor === 'any') {
160153
return cloud9
161154
}

packages/core/src/shared/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ export { activate as activateTelemetry } from './telemetry/activation'
1414
export { DefaultAwsContext } from './awsContext'
1515
export { DefaultAWSClientBuilder, ServiceOptions } from './awsClientBuilder'
1616
export { Settings } from './settings'
17-
export { initializeComputeRegion } from './extensionUtilities'
17+
export * from './extensionUtilities'
18+
export * from './extensionStartup'
1819
export { RegionProvider } from './regions/regionProvider'
1920
export { Commands } from './vscode/commands2'
2021
export { getMachineId } from './vscode/env'

packages/core/src/shared/sam/activation.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import * as goLensProvider from '../codelens/goCodeLensProvider'
2525
import { SamTemplateCodeLensProvider } from '../codelens/samTemplateCodeLensProvider'
2626
import * as jsLensProvider from '../codelens/typescriptCodeLensProvider'
2727
import { ExtContext, VSCODE_EXTENSION_ID } from '../extensions'
28-
import { getIdeProperties, getIdeType, IDE, isCloud9 } from '../extensionUtilities'
28+
import { getIdeProperties, getIdeType, isCloud9 } from '../extensionUtilities'
2929
import { getLogger } from '../logger/logger'
3030
import { PerfLog } from '../logger/perfLogger'
3131
import { NoopWatcher } from '../fs/watchedFiles'
@@ -324,7 +324,7 @@ async function createYamlExtensionPrompt(): Promise<void> {
324324
// not have a marketplace or contain the YAML plugin.
325325
if (
326326
(await settings.isPromptEnabled('yamlExtPrompt')) &&
327-
getIdeType() === IDE.vscode &&
327+
getIdeType() === 'vscode' &&
328328
!vscode.extensions.getExtension(VSCODE_EXTENSION_ID.yaml)
329329
) {
330330
// Disposed immediately after showing one, so the user isn't prompted

0 commit comments

Comments
 (0)