Skip to content

Commit 13353da

Browse files
committed
start migration
1 parent fcfc106 commit 13353da

File tree

10 files changed

+135
-91
lines changed

10 files changed

+135
-91
lines changed

packages/core/scripts/build/generateServiceClient.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ async function insertServiceClientsIntoJsSdk(
106106
jsSdkPath: string,
107107
serviceClientDefinitions: ServiceClientDefinition[]
108108
): Promise<void> {
109-
serviceClientDefinitions.forEach((serviceClientDefinition) => {
109+
for (const serviceClientDefinition of serviceClientDefinitions) {
110110
const apiVersion = getApiVersion(serviceClientDefinition.serviceJsonPath)
111111

112112
// Copy the Service Json into the JS SDK for generation
@@ -116,7 +116,7 @@ async function insertServiceClientsIntoJsSdk(
116116
`${serviceClientDefinition.serviceName.toLowerCase()}-${apiVersion}.normal.json`
117117
)
118118
nodefs.copyFileSync(serviceClientDefinition.serviceJsonPath, jsSdkServiceJsonPath)
119-
})
119+
}
120120

121121
const apiMetadataPath = path.join(jsSdkPath, 'apis', 'metadata.json')
122122
await patchServicesIntoApiMetadata(
@@ -150,10 +150,9 @@ async function patchServicesIntoApiMetadata(apiMetadataPath: string, serviceName
150150

151151
const apiMetadataJson = nodefs.readFileSync(apiMetadataPath).toString()
152152
const apiMetadata = JSON.parse(apiMetadataJson) as ApiMetadata
153-
154-
serviceNames.forEach((serviceName) => {
153+
for (const serviceName of serviceNames) {
155154
apiMetadata[serviceName.toLowerCase()] = { name: serviceName }
156-
})
155+
}
157156

158157
nodefs.writeFileSync(apiMetadataPath, JSON.stringify(apiMetadata, undefined, 4))
159158
}

packages/core/scripts/lint/testLint.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ void (async () => {
1212
const mocha = new Mocha()
1313

1414
const testFiles = await glob('dist/src/testLint/**/*.test.js')
15-
testFiles.forEach((file) => {
15+
for (const file of testFiles) {
1616
mocha.addFile(file)
17-
})
17+
}
1818

1919
mocha.run((failures) => {
2020
const exitCode = failures ? 1 : 0

packages/core/src/extensionNode.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import { activate as activateThreatComposerEditor } from './threatComposer/activ
6060
import { isSsoConnection, hasScopes } from './auth/connection'
6161
import { CrashMonitoring, setContext } from './shared'
6262
import { AuthFormId } from './login/webview/vue/types'
63+
import { addAll } from './shared/utilities/collectionUtils'
6364

6465
let localize: nls.LocalizeFunc
6566

@@ -85,10 +86,11 @@ export async function activate(context: vscode.ExtensionContext) {
8586

8687
const toolkitEnvDetails = getExtEnvironmentDetails()
8788
// Splits environment details by new line, filter removes the empty string
88-
toolkitEnvDetails
89-
.split(/\r?\n/)
90-
.filter(Boolean)
91-
.forEach((line) => getLogger().info(line))
89+
const logger = getLogger()
90+
const linesToLog = toolkitEnvDetails.split(/\r?\n/).filter(Boolean)
91+
for (const line of linesToLog) {
92+
logger.info(line)
93+
}
9294

9395
globals.awsContextCommands = new AwsContextCommands(globals.regionProvider, Auth.instance)
9496
globals.schemaService = new SchemaService()
@@ -343,17 +345,19 @@ async function getAuthState(): Promise<Omit<AuthUserState, 'source'>> {
343345
const enabledScopes: Set<string> = new Set()
344346
if (Auth.instance.hasConnections) {
345347
authStatus = 'expired'
346-
;(await Auth.instance.listConnections()).forEach((conn) => {
348+
const connections = await Auth.instance.listConnections()
349+
for (const conn of connections) {
347350
const state = Auth.instance.getConnectionState(conn)
348351
if (state === 'valid') {
349352
authStatus = 'connected'
350353
}
354+
const connectionsIds = getAuthFormIdsFromConnection(conn)
355+
addAll(enabledConnections, connectionsIds)
351356

352-
getAuthFormIdsFromConnection(conn).forEach((id) => enabledConnections.add(id))
353357
if (isSsoConnection(conn)) {
354-
conn.scopes?.forEach((s) => enabledScopes.add(s))
358+
addAll(enabledScopes, conn.scopes ?? [])
355359
}
356-
})
360+
}
357361
}
358362

359363
// There may be other SSO connections in toolkit, but there is no use case for

packages/core/src/shared/utilities/collectionUtils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,3 +570,9 @@ export function isPresent<T>(value: T | undefined): value is T {
570570
export async function mapOverMap<K, V, O>(m: Map<K, V>, f: (k: K, v: V) => Promise<O>): Promise<O[]> {
571571
return await Promise.all(Array.from(m).map(async ([k, v]) => await f(k, v)))
572572
}
573+
574+
export function addAll<T>(s: Set<T>, items: T[]) {
575+
for (const item of items) {
576+
s.add(item)
577+
}
578+
}

0 commit comments

Comments
 (0)