Skip to content

Commit f0cb44b

Browse files
committed
Merge branch 'master' into lint/noStringSubDrop
2 parents 2b60e98 + 98d8324 commit f0cb44b

34 files changed

+764
-814
lines changed

.github/workflows/jscpd.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"pattern": "packages/**/*.ts",
3-
"ignore": ["**node_modules**", "**dist**", "*/scripts/*"],
3+
"ignore": ["**node_modules**", "**dist**", "**/scripts/**"],
44
"gitignore": true,
55
"threshold": 3.0,
66
"minLines": 3,

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ To run tests against a specific folder in VSCode, do any one of:
216216
$Env:TEST_DIR = "../core/src/test/foo"; npm run test
217217
```
218218
219+
#### Run jscpd ("Copy-Paste Detection")
220+
221+
If the "Copy-Paste Detection" CI job fails, you will find it useful to check things locally. To
222+
check a specific file:
223+
224+
npx jscpd --config .github/workflows/jscpd.json --pattern packages/…/src/foo.ts
225+
226+
See the [jscpd cli documentation](https://github.com/kucherenko/jscpd/tree/master/apps/jscpd) for
227+
more options.
228+
219229
### Coverage report
220230
221231
You can find the coverage report at `./coverage/amazonq/lcov-report/index.html` and `./coverage/toolkit/lcov-report/index.html` after running the tests. Tests ran from the workspace launch config won't generate a coverage report automatically because it can break file watching.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "Bug Fix",
3+
"description": "Improve `@workspace` index auto pause start strategy. "
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": "Security Scan: Auto-scan now supports JSX, TSX, Kotlin, Scala, and Shell files."
4+
}

packages/amazonq/src/extension.ts

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,8 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import {
7-
AuthUtils,
8-
CredentialsStore,
9-
LoginManager,
10-
getTelemetryMetadataForConn,
11-
initializeAuth,
12-
isAnySsoConnection,
13-
} from 'aws-core-vscode/auth'
14-
import {
15-
AuthState,
16-
AuthUtil,
17-
activate as activateCodeWhisperer,
18-
shutdown as shutdownCodeWhisperer,
19-
} from 'aws-core-vscode/codewhisperer'
6+
import { AuthUtils, CredentialsStore, LoginManager, initializeAuth } from 'aws-core-vscode/auth'
7+
import { activate as activateCodeWhisperer, shutdown as shutdownCodeWhisperer } from 'aws-core-vscode/codewhisperer'
208
import { makeEndpointsProvider, registerGenericCommands } from 'aws-core-vscode'
219
import { CommonAuthWebview } from 'aws-core-vscode/login'
2210
import {
@@ -38,15 +26,13 @@ import {
3826
globals,
3927
initialize,
4028
initializeComputeRegion,
41-
isNetworkError,
4229
messages,
4330
placeholder,
4431
setContext,
4532
setupUninstallHandler,
4633
maybeShowMinVscodeWarning,
47-
isSageMaker,
4834
} from 'aws-core-vscode/shared'
49-
import { ExtStartUpSources, telemetry } from 'aws-core-vscode/telemetry'
35+
import { ExtStartUpSources } from 'aws-core-vscode/telemetry'
5036
import { VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
5137
import { join } from 'path'
5238
import * as semver from 'semver'
@@ -161,53 +147,6 @@ export async function activateAmazonQCommon(context: vscode.ExtensionContext, is
161147
void focusAmazonQPanel.execute(placeholder, 'firstStartUp')
162148
}, 1000)
163149
}
164-
165-
await telemetry.auth_userState
166-
.run(async () => {
167-
telemetry.record({ passive: true })
168-
169-
const firstUse = AuthUtils.ExtensionUse.instance.isFirstUse()
170-
const wasUpdated = AuthUtils.ExtensionUse.instance.wasUpdated()
171-
172-
if (firstUse) {
173-
telemetry.record({ source: ExtStartUpSources.firstStartUp })
174-
} else if (wasUpdated) {
175-
telemetry.record({ source: ExtStartUpSources.update })
176-
} else {
177-
telemetry.record({ source: ExtStartUpSources.reload })
178-
}
179-
180-
let authState: AuthState = 'disconnected'
181-
try {
182-
// May call connection validate functions that try to refresh the token.
183-
// This could result in network errors.
184-
authState = (await AuthUtil.instance.getChatAuthState(false)).codewhispererChat
185-
} catch (err) {
186-
if (
187-
isNetworkError(err) &&
188-
AuthUtil.instance.conn &&
189-
AuthUtil.instance.auth.getConnectionState(AuthUtil.instance.conn) === 'valid'
190-
) {
191-
authState = 'connectedWithNetworkError'
192-
} else {
193-
throw err
194-
}
195-
}
196-
const currConn = AuthUtil.instance.conn
197-
if (currConn !== undefined && !(isAnySsoConnection(currConn) || isSageMaker())) {
198-
getLogger().error(`Current Amazon Q connection is not SSO, type is: %s`, currConn?.type)
199-
}
200-
201-
telemetry.record({
202-
authStatus:
203-
authState === 'connected' || authState === 'expired' || authState === 'connectedWithNetworkError'
204-
? authState
205-
: 'notConnected',
206-
authEnabledConnections: AuthUtils.getAuthFormIdsFromConnection(currConn).join(','),
207-
...(await getTelemetryMetadataForConn(currConn)),
208-
})
209-
})
210-
.catch((err) => getLogger().error('Error collecting telemetry for auth_userState: %s', err))
211150
}
212151

213152
export async function deactivateCommon() {

packages/amazonq/src/extensionNode.ts

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@ import * as vscode from 'vscode'
77
import { activateAmazonQCommon, amazonQContextPrefix, deactivateCommon } from './extension'
88
import { DefaultAmazonQAppInitContext } from 'aws-core-vscode/amazonq'
99
import { activate as activateQGumby } from 'aws-core-vscode/amazonqGumby'
10-
import { ExtContext, globals, CrashMonitoring } from 'aws-core-vscode/shared'
10+
import { ExtContext, globals, CrashMonitoring, getLogger, isNetworkError, isSageMaker } from 'aws-core-vscode/shared'
1111
import { filetypes, SchemaService } from 'aws-core-vscode/sharedNode'
1212
import { updateDevMode } from 'aws-core-vscode/dev'
1313
import { CommonAuthViewProvider } from 'aws-core-vscode/login'
1414
import { isExtensionActive, VSCODE_EXTENSION_ID } from 'aws-core-vscode/utils'
1515
import { registerSubmitFeedback } from 'aws-core-vscode/feedback'
1616
import { DevOptions } from 'aws-core-vscode/dev'
17-
import { Auth } from 'aws-core-vscode/auth'
17+
import { Auth, AuthUtils, getTelemetryMetadataForConn, isAnySsoConnection } from 'aws-core-vscode/auth'
1818
import api from './api'
1919
import { activate as activateCWChat } from './app/chat/activation'
2020
import { beta } from 'aws-core-vscode/dev'
21+
import { activate as activateNotifications } from 'aws-core-vscode/notifications'
22+
import { AuthState, AuthUtil } from 'aws-core-vscode/codewhisperer'
23+
import { telemetry, AuthUserState } from 'aws-core-vscode/telemetry'
2124

2225
export async function activate(context: vscode.ExtensionContext) {
2326
// IMPORTANT: No other code should be added to this function. Place it in one of the following 2 functions where appropriate.
@@ -61,6 +64,50 @@ async function activateAmazonQNode(context: vscode.ExtensionContext) {
6164

6265
await setupDevMode(context)
6366
await beta.activate(context)
67+
68+
// TODO: Should probably emit for web as well.
69+
// Will the web metric look the same?
70+
const authState = await getAuthState()
71+
telemetry.auth_userState.emit({
72+
passive: true,
73+
result: 'Succeeded',
74+
source: AuthUtils.ExtensionUse.instance.sourceForTelemetry(),
75+
...authState,
76+
})
77+
78+
await activateNotifications(context, authState, getAuthState)
79+
}
80+
81+
async function getAuthState(): Promise<Omit<AuthUserState, 'source'>> {
82+
let authState: AuthState = 'disconnected'
83+
try {
84+
// May call connection validate functions that try to refresh the token.
85+
// This could result in network errors.
86+
authState = (await AuthUtil.instance.getChatAuthState(false)).codewhispererChat
87+
} catch (err) {
88+
if (
89+
isNetworkError(err) &&
90+
AuthUtil.instance.conn &&
91+
AuthUtil.instance.auth.getConnectionState(AuthUtil.instance.conn) === 'valid'
92+
) {
93+
authState = 'connectedWithNetworkError'
94+
} else {
95+
throw err
96+
}
97+
}
98+
const currConn = AuthUtil.instance.conn
99+
if (currConn !== undefined && !(isAnySsoConnection(currConn) || isSageMaker())) {
100+
getLogger().error(`Current Amazon Q connection is not SSO, type is: %s`, currConn?.type)
101+
}
102+
103+
return {
104+
authStatus:
105+
authState === 'connected' || authState === 'expired' || authState === 'connectedWithNetworkError'
106+
? authState
107+
: 'notConnected',
108+
authEnabledConnections: AuthUtils.getAuthFormIdsFromConnection(currConn).join(','),
109+
...(await getTelemetryMetadataForConn(currConn)),
110+
}
64111
}
65112

66113
/**

packages/amazonq/test/unit/codewhisperer/util/securityScanLanguageContext.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ describe('securityScanLanguageContext', function () {
1717
['javascript', true],
1818
['typescript', true],
1919
['jsx', false],
20-
['javascriptreact', false],
21-
['typescriptreact', false],
20+
['javascriptreact', true],
21+
['typescriptreact', true],
2222
['tsx', false],
2323
['csharp', true],
2424
['python', true],
2525
['c', true],
2626
['cpp', true],
2727
['go', true],
28-
['kotlin', false],
28+
['kotlin', true],
2929
['php', true],
3030
['ruby', true],
3131
['rust', false],
32-
['scala', false],
33-
['shellscript', false],
32+
['scala', true],
33+
['shellscript', true],
3434
['sql', false],
3535
['json', true],
3636
['yaml', true],
@@ -92,7 +92,9 @@ describe('securityScanLanguageContext', function () {
9292
['java', 'java'],
9393
['python', 'python'],
9494
['javascript', 'javascript'],
95+
['javascriptreact', 'javascript'],
9596
['typescript', 'typescript'],
97+
['typescriptreact', 'typescript'],
9698
['csharp', 'csharp'],
9799
['go', 'go'],
98100
['ruby', 'ruby'],
@@ -112,6 +114,9 @@ describe('securityScanLanguageContext', function () {
112114
['java-properties', 'plaintext'],
113115
['go.mod', 'plaintext'],
114116
['go.sum', 'plaintext'],
117+
['kotlin', 'kotlin'],
118+
['scala', 'scala'],
119+
['shellscript', 'shell'],
115120
]
116121

117122
for (const [securityScanLanguageId, expectedCwsprLanguageId] of securityScanLanguageIds) {

packages/core/src/amazonq/lsp/lspController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export interface Manifest {
6666
}
6767
const manifestUrl = 'https://aws-toolkit-language-servers.amazonaws.com/q-context/manifest.json'
6868
// this LSP client in Q extension is only going to work with these LSP server versions
69-
const supportedLspServerVersions = ['0.1.24']
69+
const supportedLspServerVersions = ['0.1.25']
7070

7171
const nodeBinName = process.platform === 'win32' ? 'node.exe' : 'node'
7272

0 commit comments

Comments
 (0)