Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/amazonq/test/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*/

import { runTests } from 'aws-core-vscode/test'
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
import { VSCODE_EXTENSION_ID_CONSTANTS } from 'aws-core-vscode/utils'

export function run(): Promise<void> {
return runTests(process.env.TEST_DIR ?? 'test/e2e', VSCODE_EXTENSION_ID.amazonq, [
return runTests(process.env.TEST_DIR ?? 'test/e2e', VSCODE_EXTENSION_ID_CONSTANTS.amazonq, [
'../../core/dist/src/testInteg/globalSetup.test.ts',
])
}
4 changes: 2 additions & 2 deletions packages/amazonq/test/unit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*/

import { runTests } from 'aws-core-vscode/test'
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
import { VSCODE_EXTENSION_ID_CONSTANTS } from 'aws-core-vscode/utils'

export function run(): Promise<void> {
return runTests(process.env.TEST_DIR ?? ['test/unit'], VSCODE_EXTENSION_ID.amazonq, [
return runTests(process.env.TEST_DIR ?? ['test/unit'], VSCODE_EXTENSION_ID_CONSTANTS.amazonq, [
'../../core/dist/src/test/globalSetup.test.ts',
])
}
6 changes: 3 additions & 3 deletions packages/amazonq/test/web/testRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* The following was influenced by this guide: https://code.visualstudio.com/api/extension-guides/web-extensions
*/

import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
import { VSCODE_EXTENSION_ID_CONSTANTS } from 'aws-core-vscode/utils'
import 'mocha' // Imports mocha for the browser, defining the `mocha` global.
import * as vscode from 'vscode'

Expand Down Expand Up @@ -47,12 +47,12 @@ function gatherTestFiles() {
* So this function ensures the extension has fully activated.
*/
async function activateExtension() {
const extId = VSCODE_EXTENSION_ID.amazonq
const extId = VSCODE_EXTENSION_ID_CONSTANTS.amazonq
const ext = vscode.extensions.getExtension(extId)
if (!ext) {
throw new Error(`Extension '${extId}' not found, can't activate it to run tests.`)
}
await vscode.extensions.getExtension(VSCODE_EXTENSION_ID.amazonq)?.activate()
await vscode.extensions.getExtension(VSCODE_EXTENSION_ID_CONSTANTS.amazonq)?.activate()
}

function runMochaTests(resolve: (value: void | PromiseLike<void>) => void, reject: (reason?: any) => void) {
Expand Down
28 changes: 14 additions & 14 deletions packages/core/scripts/test/launchTestUtilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import packageJson from '../../package.json'
import { downloadAndUnzipVSCode, resolveCliArgsFromVSCodeExecutablePath } from '@vscode/test-electron'
import { join, resolve } from 'path'
import { runTests } from '@vscode/test-electron'
import { VSCODE_EXTENSION_ID } from '../../src/shared/extensions'
import { VSCODE_EXTENSION_ID_CONSTANTS } from '../../src/shared/extensionIds'
import { TestOptions } from '@vscode/test-electron/out/runTest'

const envvarVscodeTestVersion = 'VSCODE_TEST_VERSION'
Expand Down Expand Up @@ -79,14 +79,14 @@ async function getVSCodeCliArgs(params: {
if (params.suite === 'integration' || params.suite === 'e2e') {
disableExtensionsArgs = await getCliArgsToDisableExtensions(params.vsCodeExecutablePath, {
except: [
VSCODE_EXTENSION_ID.python,
VSCODE_EXTENSION_ID.yaml,
VSCODE_EXTENSION_ID.jupyter,
VSCODE_EXTENSION_ID.go,
VSCODE_EXTENSION_ID.java,
VSCODE_EXTENSION_ID.javadebug,
VSCODE_EXTENSION_ID.git,
VSCODE_EXTENSION_ID.remotessh,
VSCODE_EXTENSION_ID_CONSTANTS.python,
VSCODE_EXTENSION_ID_CONSTANTS.yaml,
VSCODE_EXTENSION_ID_CONSTANTS.jupyter,
VSCODE_EXTENSION_ID_CONSTANTS.go,
VSCODE_EXTENSION_ID_CONSTANTS.java,
VSCODE_EXTENSION_ID_CONSTANTS.javadebug,
VSCODE_EXTENSION_ID_CONSTANTS.git,
VSCODE_EXTENSION_ID_CONSTANTS.remotessh.id,
],
})
disableWorkspaceTrustArg = [disableWorkspaceTrust]
Expand Down Expand Up @@ -160,11 +160,11 @@ async function setupVSCodeTestInstance(suite: SuiteName): Promise<string> {

// Only certain test suites require specific vscode extensions to be installed
if (suite === 'e2e' || suite === 'integration') {
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.python)
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.yaml)
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.go)
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.java)
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID.javadebug)
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID_CONSTANTS.python)
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID_CONSTANTS.yaml)
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID_CONSTANTS.go)
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID_CONSTANTS.java)
await installVSCodeExtension(vsCodeExecutablePath, VSCODE_EXTENSION_ID_CONSTANTS.javadebug)
}

console.log('VS Code Test instance has been set up')
Expand Down
37 changes: 37 additions & 0 deletions packages/core/src/shared/extensionIds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

// eslint-disable-next-line @typescript-eslint/naming-convention
export const VSCODE_REMOTE_SSH_EXTENSION = {
vscode: {
id: 'ms-vscode-remote.remote-ssh',
minVersion: '0.74.0',
},
cursor: {
id: 'anysphere.remote-ssh',
minVersion: '1.0.2',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we decide this version? latest version?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest tested version

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have keep updating the Id for any remote ssh update from cursor?

},
} as const

/**
* Extension IDs that don't require runtime vscode access.
* Safe to import in test environments.
*/
// eslint-disable-next-line @typescript-eslint/naming-convention
export const VSCODE_EXTENSION_ID_CONSTANTS = {
awstoolkit: 'amazonwebservices.aws-toolkit-vscode',
amazonq: 'amazonwebservices.amazon-q-vscode',
python: 'ms-python.python',
// python depends on jupyter plugin
jupyter: 'ms-toolsai.jupyter',
yaml: 'redhat.vscode-yaml',
go: 'golang.go',
java: 'redhat.java',
javadebug: 'vscjava.vscode-java-debug',
dotnet: 'ms-dotnettools.csdevkit',
git: 'vscode.git',
// default to VSCode in test environment
remotessh: VSCODE_REMOTE_SSH_EXTENSION.vscode,
} as const
34 changes: 19 additions & 15 deletions packages/core/src/shared/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,30 @@ import { TelemetryService } from './telemetry/telemetryService'
import { CredentialsStore } from '../auth/credentials/store'
import { SamCliContext } from './sam/cli/samCliContext'
import { UriHandler } from './vscode/uriHandler'
import { VSCODE_EXTENSION_ID_CONSTANTS, VSCODE_REMOTE_SSH_EXTENSION } from './extensionIds'

// Determine the remote SSH extension based on the editor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we iterate the VSCODE_REMOTE_SSH_EXTENSION to avoid if-else logic? It would be more open-close compatible.

const getRemoteSshExtension = () => {
const appName = vscode?.env?.appName?.toLowerCase()

if (appName?.includes('cursor')) {
return VSCODE_REMOTE_SSH_EXTENSION.cursor
}

return VSCODE_REMOTE_SSH_EXTENSION.vscode
}

// For actual use in IDE, not test environment
// eslint-disable-next-line @typescript-eslint/naming-convention
export const VSCODE_EXTENSION_ID = {
awstoolkit: 'amazonwebservices.aws-toolkit-vscode',
amazonq: 'amazonwebservices.amazon-q-vscode',
python: 'ms-python.python',
// python depends on jupyter plugin
jupyter: 'ms-toolsai.jupyter',
yaml: 'redhat.vscode-yaml',
go: 'golang.go',
java: 'redhat.java',
javadebug: 'vscjava.vscode-java-debug',
dotnet: 'ms-dotnettools.csdevkit',
git: 'vscode.git',
remotessh: 'ms-vscode-remote.remote-ssh',
...VSCODE_EXTENSION_ID_CONSTANTS,
get remotessh() {
return getRemoteSshExtension()
},
} as const

export const vscodeExtensionMinVersion = {
remotessh: '0.74.0',
}
// Re-export for backward compatibility
export { VSCODE_REMOTE_SSH_EXTENSION }

/** @deprecated Use `extensionGlobals.ts:globals` instead. */
export interface ExtContext {
Expand Down
12 changes: 6 additions & 6 deletions packages/core/src/shared/remoteSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Settings } from '../shared/settings'
import { showConfirmationMessage, showMessageWithCancel } from './utilities/messages'
import { CancellationError, Timeout } from './utilities/timeoutUtils'
import { isExtensionInstalled, showInstallExtensionMsg } from './utilities/vsCodeUtils'
import { VSCODE_EXTENSION_ID, vscodeExtensionMinVersion } from './extensions'
import { VSCODE_EXTENSION_ID } from './extensions'
import { Err, Result } from '../shared/utilities/result'
import { ToolkitError, UnknownError } from './errors'
import { getLogger } from './logger/logger'
Expand Down Expand Up @@ -108,19 +108,19 @@ export async function ensureDependencies(): Promise<Result<DependencyPaths, Canc
}

export async function ensureRemoteSshInstalled(): Promise<void> {
if (!isExtensionInstalled(VSCODE_EXTENSION_ID.remotessh, vscodeExtensionMinVersion.remotessh)) {
if (!isExtensionInstalled(VSCODE_EXTENSION_ID.remotessh.id, VSCODE_EXTENSION_ID.remotessh.minVersion)) {
showInstallExtensionMsg(
VSCODE_EXTENSION_ID.remotessh,
VSCODE_EXTENSION_ID.remotessh.id,
'Remote SSH',
'Connecting to Dev Environment',
vscodeExtensionMinVersion.remotessh
VSCODE_EXTENSION_ID.remotessh.minVersion
)

if (isExtensionInstalled(VSCODE_EXTENSION_ID.remotessh)) {
if (isExtensionInstalled(VSCODE_EXTENSION_ID.remotessh.id)) {
throw new ToolkitError('Remote SSH extension version is too low', {
cancelled: true,
code: RemoteSessionError.ExtensionVersionTooLow,
details: { expected: vscodeExtensionMinVersion.remotessh },
details: { expected: VSCODE_EXTENSION_ID.remotessh.minVersion },
})
} else {
throw new ToolkitError('Remote SSH extension not installed', {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/shared/utilities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

export { isExtensionInstalled, isExtensionActive } from './vsCodeUtils'
export { VSCODE_EXTENSION_ID } from '../extensions'
export { VSCODE_EXTENSION_ID_CONSTANTS } from '../extensionIds'
export * from './functionUtils'
export * as messageUtils from './messages'
export * as CommentUtils from './commentUtils'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import * as sinon from 'sinon'
import * as vscode from 'vscode'
import assert from 'assert'
import { UriHandler } from '../../../shared/vscode/uriHandler'
import { VSCODE_EXTENSION_ID } from '../../../shared/extensions'
import { VSCODE_EXTENSION_ID_CONSTANTS } from '../../../shared/extensionIds'
import { register } from '../../../awsService/sagemaker/uriHandlers'

function createConnectUri(params: { [key: string]: string }): vscode.Uri {
const query = Object.entries(params)
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
.join('&')
return vscode.Uri.parse(`vscode://${VSCODE_EXTENSION_ID.awstoolkit}/connect/sagemaker?${query}`)
return vscode.Uri.parse(`vscode://${VSCODE_EXTENSION_ID_CONSTANTS.awstoolkit}/connect/sagemaker?${query}`)
}

describe('SageMaker URI handler', function () {
Expand Down
8 changes: 5 additions & 3 deletions packages/core/src/test/codecatalyst/uriHandlers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as vscode from 'vscode'
import assert from 'assert'
import { register } from '../../codecatalyst/uriHandlers'
import { UriHandler } from '../../shared/vscode/uriHandler'
import { VSCODE_EXTENSION_ID } from '../../shared/extensions'
import { VSCODE_EXTENSION_ID_CONSTANTS } from '../../shared/extensionIds'
import { CodeCatalystClient } from '../../shared/clients/codecatalystClient'
import { SeverityLevel } from '../shared/vscode/message'
import { getTestWindow } from '../shared/vscode/window'
Expand All @@ -18,14 +18,16 @@ import { builderIdStartUrl } from '../../auth/sso/constants'
type Stub<T extends (...args: any[]) => any> = sinon.SinonStub<Parameters<T>, ReturnType<T>>

function createCloneUri(target: string): vscode.Uri {
return vscode.Uri.parse(`vscode://${VSCODE_EXTENSION_ID.awstoolkit}/clone?url=${encodeURIComponent(target)}`)
return vscode.Uri.parse(
`vscode://${VSCODE_EXTENSION_ID_CONSTANTS.awstoolkit}/clone?url=${encodeURIComponent(target)}`
)
}

function createConnectUri(params: { [key: string]: any }): vscode.Uri {
const encoded = Object.entries(params)
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(v)}`)
.join('&')
return vscode.Uri.parse(`vscode://${VSCODE_EXTENSION_ID.awstoolkit}/connect/codecatalyst?${encoded}`)
return vscode.Uri.parse(`vscode://${VSCODE_EXTENSION_ID_CONSTANTS.awstoolkit}/connect/codecatalyst?${encoded}`)
}

// Tests involving `UriHandler` should _not_ couple the URI paths to the implementation.
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/test/shared/utilities/vscodeUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import assert from 'assert'
import { VSCODE_EXTENSION_ID } from '../../../shared/extensions'
import { VSCODE_EXTENSION_ID_CONSTANTS } from '../../../shared/extensionIds'
import * as vscodeUtil from '../../../shared/utilities/vsCodeUtils'
import * as vscode from 'vscode'
import { getExcludePattern } from '../../../shared/fs/watchedFiles'
Expand All @@ -18,8 +18,8 @@ describe('vscodeUtils', async function () {

assert.deepStrictEqual(vscodeUtil.isExtensionActive('invalid.extension'), false)

await vscodeUtil.activateExtension(VSCODE_EXTENSION_ID.awstoolkit, false)
assert.deepStrictEqual(vscodeUtil.isExtensionActive(VSCODE_EXTENSION_ID.awstoolkit), true)
await vscodeUtil.activateExtension(VSCODE_EXTENSION_ID_CONSTANTS.awstoolkit, false)
assert.deepStrictEqual(vscodeUtil.isExtensionActive(VSCODE_EXTENSION_ID_CONSTANTS.awstoolkit), true)
})

it('globDirPatterns()', async function () {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/testE2E/codecatalyst/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ describe('Test how this codebase uses the CodeCatalyst API', function () {
})

it('prompts to install the ssh extension if not available', async function () {
if (isExtensionInstalled(VSCODE_EXTENSION_ID.remotessh)) {
if (isExtensionInstalled(VSCODE_EXTENSION_ID.remotessh.id)) {
skipTest(this, 'remote ssh already installed')
}

Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/test/e2e/cloudformation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

import { runTests } from 'aws-core-vscode/test'
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
import { VSCODE_EXTENSION_ID_CONSTANTS } from 'aws-core-vscode/utils'

export function run(): Promise<void> {
return runTests(
process.env.TEST_DIR ?? ['../../core/dist/src/testE2E/cloudformation'],
VSCODE_EXTENSION_ID.awstoolkit,
VSCODE_EXTENSION_ID_CONSTANTS.awstoolkit,
['../../core/dist/src/testInteg/globalSetup.test.ts']
)
}
4 changes: 2 additions & 2 deletions packages/toolkit/test/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

import { runTests } from 'aws-core-vscode/test'
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
import { VSCODE_EXTENSION_ID_CONSTANTS } from 'aws-core-vscode/utils'

export function run(): Promise<void> {
return runTests(
process.env.TEST_DIR ?? ['test/e2e', '../../core/dist/src/testE2E'],
VSCODE_EXTENSION_ID.awstoolkit,
VSCODE_EXTENSION_ID_CONSTANTS.awstoolkit,
['../../core/dist/src/testInteg/globalSetup.test.ts']
)
}
4 changes: 2 additions & 2 deletions packages/toolkit/test/integ/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

import { runTests } from 'aws-core-vscode/test'
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
import { VSCODE_EXTENSION_ID_CONSTANTS } from 'aws-core-vscode/utils'

export function run(): Promise<void> {
return runTests(
process.env.TEST_DIR ?? ['test/integ', '../../core/dist/src/testInteg'],
VSCODE_EXTENSION_ID.awstoolkit,
VSCODE_EXTENSION_ID_CONSTANTS.awstoolkit,
['../../core/dist/src/testInteg/globalSetup.test.ts']
)
}
10 changes: 6 additions & 4 deletions packages/toolkit/test/unit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
*/

import { runTests } from 'aws-core-vscode/test'
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
import { VSCODE_EXTENSION_ID_CONSTANTS } from 'aws-core-vscode/utils'

export function run(): Promise<void> {
return runTests(process.env.TEST_DIR ?? ['test/unit', '../../core/dist/src/test'], VSCODE_EXTENSION_ID.awstoolkit, [
'../../core/dist/src/test/globalSetup.test.ts',
])
return runTests(
process.env.TEST_DIR ?? ['test/unit', '../../core/dist/src/test'],
VSCODE_EXTENSION_ID_CONSTANTS.awstoolkit,
['../../core/dist/src/test/globalSetup.test.ts']
)
}
Loading