Skip to content

Commit

Permalink
fix(amazonq): improve autoinstall message aws#4737
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmk3 authored Apr 18, 2024
1 parent b899e82 commit a857688
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions packages/amazonq/src/extensionShared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
DefaultAWSClientBuilder,
globals,
RegionProvider,
getLogger,
} from 'aws-core-vscode/shared'
import { initializeAuth, CredentialsStore, LoginManager, AuthUtils } from 'aws-core-vscode/auth'
import { makeEndpointsProvider, registerCommands } from 'aws-core-vscode'
Expand All @@ -45,21 +46,27 @@ export async function activateShared(context: vscode.ExtensionContext) {
const toolkit = vscode.extensions.getExtension(VSCODE_EXTENSION_ID.awstoolkit)
if (toolkit) {
const toolkitVersion = semver.coerce(toolkit.packageJSON.version)
// XXX: can't use `SemVer.prerelease` because Toolkit "prerelease" (git sha) is not a valid
// semver prerelease: it may start with a number.
const isDevVersion = toolkit.packageJSON.version.toString().includes('-')
if (toolkitVersion && toolkitVersion.major < 3 && !isDevVersion) {
await vscode.commands
.executeCommand('workbench.extensions.installExtension', VSCODE_EXTENSION_ID.awstoolkit)
.then(
void vscode.window
.showInformationMessage(
`The Amazon Q extension is incompatible with AWS Toolkit versions 2.9 and below. Your AWS Toolkit was updated to version 3.0 or later.`,
'Reload Now'
)
.then(async resp => {
if (resp === 'Reload Now') {
await vscode.commands.executeCommand('workbench.action.reloadWindow')
}
})
() =>
vscode.window
.showInformationMessage(
`The Amazon Q extension is incompatible with AWS Toolkit ${toolkitVersion} and older. Your AWS Toolkit was updated to version 3.0 or later.`,
'Reload Now'
)
.then(async resp => {
if (resp === 'Reload Now') {
await vscode.commands.executeCommand('workbench.action.reloadWindow')
}
}),
reason => {
getLogger().error('workbench.extensions.installExtension failed: %O', reason)
}
)
return
}
Expand Down

0 comments on commit a857688

Please sign in to comment.