Skip to content

Commit 35e1686

Browse files
feat(amazonq): Log attribution notice when downloading language server (aws#7193)
## Problem: Legal requires us to log the attribution notice when downloading the language server. We do not currently do this. ## Solution: - What our message looks like: `lsp: Installing 'AmazonQ' Language Server v0.1.0-alpha.100 to /Users/nkomonen/Library/Caches/aws/toolkits/language-servers/AmazonQ/0.1.0-alpha.100 (Attribution notice can be found at https://dhi0h88q3j9q6.cloudfront.net/6a0c7aa8-8b63-43a7-b14b-ee7594a29c9d/THIRD_PARTY_LICENSES)` - This log message is in the generic part of our LSP downloader, and will show for all LSPs downloaded. The link to the attribution notice is already part of the manifest, so we grab it from there. --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license. Signed-off-by: nkomonen-amazon <[email protected]>
1 parent 907c784 commit 35e1686

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

packages/core/src/shared/lsp/baseLspInstaller.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export abstract class BaseLspInstaller<T extends ResourcePaths = ResourcePaths,
4141
const manifest = await new ManifestResolver(manifestUrl, id, suppressPromptPrefix).resolve()
4242
const installationResult = await new LanguageServerResolver(
4343
manifest,
44-
id,
44+
id, // TODO: We may want a display name instead of the ID
4545
new Range(supportedVersions, {
4646
includePrerelease: true,
4747
}),

packages/core/src/shared/lsp/lspResolver.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class LanguageServerResolver {
135135
): Promise<LspResult> {
136136
const timeout = await this.showDownloadProgress()
137137
try {
138-
if (await this.downloadRemoteTargetContent(targetContents, latestVersion.serverVersion, timeout)) {
138+
if (await this.downloadRemoteTargetContent(targetContents, latestVersion, timeout)) {
139139
return {
140140
location: 'remote',
141141
version: latestVersion.serverVersion,
@@ -236,8 +236,8 @@ export class LanguageServerResolver {
236236
* true, if all of the contents were successfully downloaded and unzipped
237237
* false, if any of the contents failed to download or unzip
238238
*/
239-
private async downloadRemoteTargetContent(contents: TargetContent[], version: string, timeout: Timeout) {
240-
const downloadDirectory = this.getDownloadDirectory(version)
239+
private async downloadRemoteTargetContent(contents: TargetContent[], lspVersion: LspVersion, timeout: Timeout) {
240+
const downloadDirectory = this.getDownloadDirectory(lspVersion.serverVersion)
241241

242242
if (!(await fs.existsDir(downloadDirectory))) {
243243
await fs.mkdir(downloadDirectory)
@@ -273,6 +273,12 @@ export class LanguageServerResolver {
273273

274274
const filesToDownload = await lspSetupStage('validate', async () => (await Promise.all(verifyTasks)).flat())
275275

276+
// We were instructed by legal to show this message
277+
const thirdPartyLicenses = lspVersion.thirdPartyLicenses
278+
logger.info(
279+
`Installing '${this.lsName}' Language Server v${lspVersion.serverVersion} to: ${downloadDirectory}${thirdPartyLicenses ? ` (Attribution notice can be found at ${thirdPartyLicenses})` : ''}`
280+
)
281+
276282
for (const file of filesToDownload) {
277283
await fs.writeFile(`${downloadDirectory}/${file.filename}`, file.data)
278284
}

packages/core/src/shared/lsp/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ export interface LspVersion {
7272
serverVersion: string
7373
isDelisted: boolean
7474
targets: Target[]
75+
/**
76+
* I'm not sure if this **always** exists (couldn't find it in the spec)
77+
*/
78+
thirdPartyLicenses?: string
7579
}
7680

7781
export interface Manifest {

0 commit comments

Comments
 (0)