Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
- run: npm run testCompile
- run: npm run lint

jscpd:
lint-duplicate-code:
needs: lint-commits
if: ${{ github.event_name == 'pull_request'}}
runs-on: ubuntu-latest
Expand Down
48 changes: 48 additions & 0 deletions buildspec/release/70checkmarketplace.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
version: 0.2

phases:
install:
runtime-versions:
nodejs: 16

commands:
- apt update
- apt install -y wget gpg
- curl -sSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
- install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
- sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
- apt update
- apt install -y code

pre_build:
commands:
# Check for implicit env vars passed from the release pipeline.
- test -n "${TARGET_EXTENSION}"

build:
commands:
- VERSION=$(node -e "console.log(require('./packages/${TARGET_EXTENSION}/package.json').version);")
# get extension name
- |
if [ "${TARGET_EXTENSION}" = "amazonq" ]; then
extension_name="amazonwebservices.amazon-q-vscode"
elif [ "${TARGET_EXTENSION}" = "toolkit" ]; then
extension_name="amazonwebservices.aws-toolkit-vscode"
else
echo checkmarketplace: "Unknown TARGET_EXTENSION: ${TARGET_EXTENSION}"
exit 1
fi
# keep reinstalling the extension until the desired version is updated. Otherwise fail on codebuild timeout (1 hour).
- |
while true; do
code --uninstall-extension "${extension_name}" --no-sandbox --user-data-dir /tmp/vscode
code --install-extension ${extension_name} --no-sandbox --user-data-dir /tmp/vscode
cur_version=$(code --list-extensions --show-versions --no-sandbox --user-data-dir /tmp/vscode | grep ${extension_name} | cut -d'@' -f2)
if [ "${cur_version}" = "${VERSION}" ]; then
echo "checkmarketplace: Extension ${extension_name} is updated to version '${cur_version}.'"
break
else
echo "checkmarketplace: Current version '${cur_version}' does not match expected version '${VERSION}'. Retrying..."
fi
sleep 120 # Wait for 2 minutes before retrying
done
3 changes: 2 additions & 1 deletion packages/amazonq/src/lsp/lspInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
fs,
LspResolution,
getNodeExecutableName,
cleanLspDownloads,
} from 'aws-core-vscode/shared'
import path from 'path'

Expand Down Expand Up @@ -46,7 +47,7 @@ export class AmazonQLSPResolver implements LspResolver {
const nodePath = path.join(installationResult.assetDirectory, `servers/${getNodeExecutableName()}`)
await fs.chmod(nodePath, 0o755)

// TODO Cleanup old versions of language servers
await cleanLspDownloads(manifest.versions, path.dirname(installationResult.assetDirectory))
return {
...installationResult,
resourcePaths: {
Expand Down
4 changes: 3 additions & 1 deletion packages/core/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"AWS.configuration.description.suppressPrompts": "Prompts which ask for confirmation. Checking an item suppresses the prompt.",
"AWS.configuration.enableCodeLenses": "Enable SAM hints in source code and template.yaml files",
"AWS.configuration.description.resources.enabledResources": "AWS resources to display in the 'Resources' portion of the explorer.",
"AWS.configuration.description.experiments": "Try experimental features and give feedback. Note that experimental features may be removed at any time.\n * `jsonResourceModification` - Enables basic create, update, and delete support for cloud resources via the JSON Resources explorer component.\n * `ec2RemoteConnect` - Allows interfacing with EC2 instances with options to start, stop, and establish remote connections. Remote connections are done over SSM and can be through a terminal or a remote VSCode window.",
"AWS.configuration.description.experiments": "Try experimental features and give feedback. Note that experimental features may be removed at any time.\n * `jsonResourceModification` - Enables basic create, update, and delete support for cloud resources via the JSON Resources explorer component.",
"AWS.stepFunctions.asl.format.enable.desc": "Enables the default formatter used with Amazon States Language files",
"AWS.stepFunctions.asl.maxItemsComputed.desc": "The maximum number of outline symbols and folding regions computed (limited for performance reasons).",
"AWS.configuration.description.awssam.debug.api": "API Gateway configuration",
Expand Down Expand Up @@ -295,6 +295,7 @@
"AWS.codewhisperer.customization.notification.new_customizations.learn_more": "Learn More",
"AWS.amazonq.title": "Amazon Q",
"AWS.amazonq.chat": "Chat",
"AWS.amazonq.chat.workspacecontext.enable.message": "Amazon Q: Workspace index is now enabled. You can disable it from Amazon Q settings.",
"AWS.amazonq.security": "Code Issues",
"AWS.amazonq.login": "Login",
"AWS.amazonq.learnMore": "Learn More About Amazon Q",
Expand Down Expand Up @@ -404,6 +405,7 @@
"AWS.amazonq.doc.pillText.reject": "Reject",
"AWS.amazonq.doc.pillText.makeChanges": "Make changes",
"AWS.amazonq.inline.invokeChat": "Inline chat",
"AWS.amazonq.opensettings:": "Open settings",
"AWS.toolkit.lambda.walkthrough.quickpickTitle": "Application Builder Walkthrough",
"AWS.toolkit.lambda.walkthrough.title": "Get started building your application",
"AWS.toolkit.lambda.walkthrough.description": "Your quick guide to build an application visually, iterate locally, and deploy to the cloud!",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/amazonq/lsp/workspaceInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { LanguageServerResolver } from '../../shared/lsp/lspResolver'
import { Range } from 'semver'
import { getNodeExecutableName } from '../../shared/lsp/utils/platform'
import { fs } from '../../shared/fs/fs'
import { cleanLspDownloads } from '../../shared'

const manifestUrl = 'https://aws-toolkit-language-servers.amazonaws.com/q-context/manifest.json'
// this LSP client in Q extension is only going to work with these LSP server versions
Expand All @@ -30,7 +31,7 @@ export class WorkspaceLSPResolver implements LspResolver {
const nodePath = path.join(installationResult.assetDirectory, nodeName)
await fs.chmod(nodePath, 0o755)

// TODO Cleanup old versions of language servers
await cleanLspDownloads(manifest.versions, path.basename(installationResult.assetDirectory))
return {
...installationResult,
resourcePaths: {
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/awsexplorer/regionNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { getEcsRootNode } from '../awsService/ecs/model'
import { compareTreeItems, TreeShim } from '../shared/treeview/utils'
import { Ec2ParentNode } from '../awsService/ec2/explorer/ec2ParentNode'
import { Ec2Client } from '../shared/clients/ec2Client'
import { Experiments } from '../shared/settings'

interface ServiceNode {
allRegions?: boolean
Expand Down Expand Up @@ -64,7 +63,6 @@ const serviceCandidates: ServiceNode[] = [
},
{
serviceId: 'ec2',
when: () => Experiments.instance.isExperimentEnabled('ec2RemoteConnect'),
createFn: (regionCode: string, partitionId: string) =>
new Ec2ParentNode(regionCode, partitionId, new Ec2Client(regionCode)),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/shared/clients/s3Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ export class DefaultS3Client {
* Set '' as the default prefix to ensure that the bucket's content will be displayed
* when the user has at least list access to the root of the bucket.
* https://github.com/aws/aws-toolkit-vscode/issues/4643
* @default ''
* @default ''
*/
Prefix: request.folderPath ?? defaultPrefix,
ContinuationToken: request.continuationToken,
Expand Down
37 changes: 35 additions & 2 deletions packages/core/src/shared/featureConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
ListFeatureEvaluationsResponse,
} from '../codewhisperer/client/codewhispereruserclient'
import * as vscode from 'vscode'
import * as nls from 'vscode-nls'
import { codeWhispererClient as client } from '../codewhisperer/client/codewhisperer'
import { AuthUtil } from '../codewhisperer/util/authUtil'
import { getLogger } from './logger'
Expand All @@ -19,7 +20,9 @@ import globals from './extensionGlobals'
import { getClientId, getOperatingSystem } from './telemetry/util'
import { extensionVersion } from './vscode/env'
import { telemetry } from './telemetry'
import { Auth } from '../auth'
import { Commands } from './vscode/commands2'

const localize = nls.loadMessageBundle()

export class FeatureContext {
constructor(
Expand All @@ -35,6 +38,7 @@ export const Features = {
customizationArnOverride: 'customizationArnOverride',
dataCollectionFeature: 'IDEProjectContextDataCollection',
projectContextFeature: 'ProjectContextV2',
workspaceContextFeature: 'WorkspaceContext',
test: 'testFeature',
} as const

Expand Down Expand Up @@ -83,6 +87,21 @@ export class FeatureConfigProvider {
}
}

getWorkspaceContextGroup(): 'control' | 'treatment' {
const variation = this.featureConfigs.get(Features.projectContextFeature)?.variation

switch (variation) {
case 'CONTROL':
return 'control'

case 'TREATMENT':
return 'treatment'

default:
return 'control'
}
}

public async listFeatureEvaluations(): Promise<ListFeatureEvaluationsResponse> {
const request: ListFeatureEvaluationsRequest = {
userContext: {
Expand Down Expand Up @@ -154,12 +173,26 @@ export class FeatureConfigProvider {
await vscode.commands.executeCommand('aws.amazonq.refreshStatusBar')
}
}
if (Auth.instance.isInternalAmazonUser()) {
if (this.getWorkspaceContextGroup() === 'treatment') {
// Enable local workspace index by default only once, for Amzn users.
const isSet = globals.globalState.get<boolean>('aws.amazonq.workspaceIndexToggleOn') || false
if (!isSet) {
await CodeWhispererSettings.instance.enableLocalIndex()
globals.globalState.tryUpdate('aws.amazonq.workspaceIndexToggleOn', true)

await vscode.window
.showInformationMessage(
localize(
'AWS.amazonq.chat.workspacecontext.enable.message',
'Amazon Q: Workspace index is now enabled. You can disable it from Amazon Q settings.'
),
localize('AWS.amazonq.opensettings', 'Open settings')
)
.then((r) => {
if (r === 'Open settings') {
void Commands.tryExecute('aws.amazonq.configure').then()
}
})
}
}
} catch (e) {
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/shared/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export { TabTypeDataMap } from '../amazonq/webview/ui/tabs/constants'
export * from './lsp/manifestResolver'
export * from './lsp/lspResolver'
export * from './lsp/types'
export * from './lsp/utils/cleanup'
export { default as request } from './request'
export * from './lsp/utils/platform'
export * as processUtils from './utilities/processUtils'
8 changes: 6 additions & 2 deletions packages/core/src/shared/lsp/lspResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,13 @@ export class LanguageServerResolver {
return version.targets.find((x) => x.arch === arch && x.platform === platform)
}

// lazy calls to `getApplicationSupportFolder()` to avoid failure on windows.
public static get defaultDir() {
return path.join(getApplicationSupportFolder(), `aws/toolkits/language-servers`)
}

defaultDownloadFolder() {
const applicationSupportFolder = getApplicationSupportFolder()
return path.join(applicationSupportFolder, `aws/toolkits/language-servers/${this.lsName}`)
return path.join(LanguageServerResolver.defaultDir, `${this.lsName}`)
}

private getDownloadDirectory(version: string) {
Expand Down
41 changes: 41 additions & 0 deletions packages/core/src/shared/lsp/utils/cleanup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*!
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0
*/

import path from 'path'
import { LspVersion } from '../types'
import { fs } from '../../../shared/fs/fs'
import { partition } from '../../../shared/utilities/tsUtils'
import { sort } from 'semver'

async function getDownloadedVersions(installLocation: string) {
return (await fs.readdir(installLocation)).map(([f, _], __) => f)
}

function isDelisted(manifestVersions: LspVersion[], targetVersion: string): boolean {
return manifestVersions.find((v) => v.serverVersion === targetVersion)?.isDelisted ?? false
}

/**
* Delete all delisted versions and keep the two newest versions that remain
* @param manifest
* @param downloadDirectory
*/
export async function cleanLspDownloads(manifestVersions: LspVersion[], downloadDirectory: string): Promise<void> {
const downloadedVersions = await getDownloadedVersions(downloadDirectory)
const [delistedVersions, remainingVersions] = partition(downloadedVersions, (v: string) =>
isDelisted(manifestVersions, v)
)
for (const v of delistedVersions) {
await fs.delete(path.join(downloadDirectory, v), { force: true, recursive: true })
}

if (remainingVersions.length <= 2) {
return
}

for (const v of sort(remainingVersions).slice(0, -2)) {
await fs.delete(path.join(downloadDirectory, v), { force: true, recursive: true })
}
}
3 changes: 1 addition & 2 deletions packages/core/src/shared/settings-toolkit.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ export const toolkitSettings = {
},
"aws.experiments": {
"jsonResourceModification": {},
"amazonqLSP": {},
"ec2RemoteConnect": {}
"amazonqLSP": {}
},
"aws.resources.enabledResources": {},
"aws.lambda.recentlyUploaded": {},
Expand Down
15 changes: 15 additions & 0 deletions packages/core/src/shared/utilities/tsUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ export function createFactoryFunction<T extends new (...args: any[]) => any>(cto
return (...args) => new ctor(...args)
}

/**
* Split a list into two sublists based on the result of a predicate.
* @param lst list to split
* @param pred predicate to apply to each element
* @returns two nested lists, where for all items x in the left sublist, pred(x) returns true. The remaining elements are in the right sublist.
*/
export function partition<T>(lst: T[], pred: (arg: T) => boolean): [T[], T[]] {
return lst.reduce(
([leftAcc, rightAcc], item) => {
return pred(item) ? [[...leftAcc, item], rightAcc] : [leftAcc, [...rightAcc, item]]
},
[[], []] as [T[], T[]]
)
}

type NoSymbols<T> = { [Property in keyof T]: Property extends symbol ? never : Property }[keyof T]
export type InterfaceNoSymbol<T> = Pick<T, NoSymbols<T>>
/**
Expand Down
Loading
Loading