Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
24919b7
add test for minimum ssm actions
Hweinstock Oct 11, 2024
61f95f0
refactor pathfinder
Hweinstock Oct 11, 2024
12cf3ec
fix tests
Hweinstock Oct 11, 2024
423ca0c
assert called with resulting ssh path
Hweinstock Oct 11, 2024
9a72b73
add ui tests
Hweinstock Oct 11, 2024
b741e83
rename files back
Hweinstock Oct 17, 2024
d6c052b
fix imports
Hweinstock Oct 17, 2024
b2890bd
add more testing
Hweinstock Oct 17, 2024
697f4bc
avoid unnecessary churn
Hweinstock Oct 17, 2024
b47c788
fix imports
Hweinstock Oct 17, 2024
57eb886
avoid circular dependency
Hweinstock Oct 17, 2024
8a1131d
add offset for windows calls
Hweinstock Oct 17, 2024
4071645
move tryRun back
Hweinstock Oct 17, 2024
36c133b
write tests that do not stub fs
Hweinstock Oct 17, 2024
4a55e56
remove duplicate func
Hweinstock Oct 17, 2024
a92ba99
add docstring to testUtil
Hweinstock Oct 17, 2024
c2e17bd
add tests for path utility;
Hweinstock Oct 17, 2024
4cb7b3c
avoid moving function
Hweinstock Oct 17, 2024
60c2bed
refactor
Hweinstock Oct 17, 2024
5c48e66
avoid with paradigm
Hweinstock Oct 17, 2024
eff906a
make param optional
Hweinstock Oct 17, 2024
622c4d2
try case sensitive version
Hweinstock Oct 18, 2024
07026be
add sanity tests for util
Hweinstock Oct 18, 2024
f13cf65
avoid .cmd extension
Hweinstock Oct 18, 2024
a11c2fc
remove cmd
Hweinstock Oct 18, 2024
b910f85
remove linux-command in exec
Hweinstock Oct 18, 2024
bb1c3b9
add tests for executable file
Hweinstock Oct 18, 2024
5697da1
add extension to make it executable
Hweinstock Oct 18, 2024
b57053d
try .cmd instead of .exe
Hweinstock Oct 18, 2024
ba9fa6f
replace manual childprocess with tryRun
Hweinstock Oct 18, 2024
ff0cf37
remove cmd extension
Hweinstock Oct 18, 2024
bd292c2
re-write unit tests
Hweinstock Oct 18, 2024
6bec701
adjust tests
Hweinstock Oct 18, 2024
3d1740a
adjust windows cases
Hweinstock Oct 18, 2024
6b1bf0f
make a windows specific test
Hweinstock Oct 18, 2024
69f09ab
fix tests to be windows/mac specific
Hweinstock Oct 18, 2024
d10f613
Update packages/core/src/test/shared/utilities/testUtils.test.ts
Hweinstock Oct 18, 2024
cfcc6bb
Update packages/core/src/test/testUtil.ts
Hweinstock Oct 18, 2024
4b0785f
refactor to shallow copy
Hweinstock Oct 18, 2024
deff2a2
Update packages/core/src/test/shared/utilities/pathFind.test.ts
Hweinstock Oct 21, 2024
c6f02ac
Update packages/core/src/test/shared/utilities/pathFind.test.ts
Hweinstock Oct 21, 2024
5810995
Update packages/core/src/test/shared/utilities/pathFind.test.ts
Hweinstock Oct 21, 2024
2d0d4fb
remove unneeded utility function
Hweinstock Oct 21, 2024
912d579
fix dupe var in test
Hweinstock Oct 21, 2024
f2441ea
Merge branch 'master' into securityTests
Hweinstock Oct 21, 2024
7e7b0cb
write only to PATH
Hweinstock Oct 21, 2024
a28c33e
rewrite only the PATH var
Hweinstock Oct 21, 2024
3c80c2f
skip path test on windows, avoid generate assertion on windows
Hweinstock Oct 21, 2024
b82672a
Update packages/core/src/test/shared/utilities/pathFind.test.ts
Hweinstock Oct 21, 2024
e103c1e
Update packages/core/src/test/shared/utilities/pathFind.test.ts
Hweinstock Oct 21, 2024
a8880de
Update packages/core/src/test/shared/utilities/testUtils.test.ts
Hweinstock Oct 21, 2024
6cc9743
fix env ref
Hweinstock Oct 21, 2024
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
14 changes: 10 additions & 4 deletions packages/core/src/awsService/ec2/sshKeyPair.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
*/
import { fs } from '../../shared'
import { ToolkitError } from '../../shared/errors'
import { tryRun } from '../../shared/utilities/pathFind'
import { Timeout } from '../../shared/utilities/timeoutUtils'
import { findAsync } from '../../shared/utilities/collectionUtils'
import { RunParameterContext } from '../../shared/utilities/processUtils'
import { PathFinder } from '../../shared/utilities/pathFinder'

type sshKeyType = 'rsa' | 'ed25519'

Expand Down Expand Up @@ -48,9 +48,15 @@ export class SshKeyPair {
const overrideKeys = async (_t: string, proc: RunParameterContext) => {
await proc.send('yes')
}
return !(await tryRun('ssh-keygen', ['-t', keyType, '-N', '', '-q', '-f', keyPath], 'yes', 'unknown key type', {
onStdout: overrideKeys,
}))
return !(await PathFinder.tryRun(
'ssh-keygen',
['-t', keyType, '-N', '', '-q', '-f', keyPath],
'yes',
'unknown key type',
{
onStdout: overrideKeys,
}
))
}

public static async tryKeyTypes(keyPath: string, keyTypes: sshKeyType[]): Promise<boolean> {
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/codewhisperer/commands/basicCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import { ToolkitError, getTelemetryReason, getTelemetryReasonDesc } from '../../
import { isRemoteWorkspace } from '../../shared/vscode/env'
import { isBuilderIdConnection } from '../../auth/connection'
import globals from '../../shared/extensionGlobals'
import { getVscodeCliPath, tryRun } from '../../shared/utilities/pathFind'
import { setContext } from '../../shared/vscode/setContext'
import pathFinder, { PathFinder } from '../../shared/utilities/pathFinder'

const MessageTimeOut = 5_000

Expand Down Expand Up @@ -315,7 +315,7 @@ export const installAmazonQExtension = Commands.declare(
* installExtension will fail on remote environments when the amazon q extension is already installed locally.
* Until thats fixed we need to manually install the amazon q extension using the cli
*/
const vscPath = await getVscodeCliPath()
const vscPath = await pathFinder.getVscodeCliPath()
if (!vscPath) {
throw new ToolkitError('installAmazonQ: Unable to find VSCode CLI path', {
code: 'CodeCLINotFound',
Expand All @@ -328,7 +328,7 @@ export const installAmazonQExtension = Commands.declare(
},
(progress, token) => {
progress.report({ message: 'Installing Amazon Q' })
return tryRun(vscPath, ['--install-extension', VSCODE_EXTENSION_ID.amazonq])
return PathFinder.tryRun(vscPath, ['--install-extension', VSCODE_EXTENSION_ID.amazonq])
}
)
return
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/shared/remoteSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import { getLogger } from './logger/logger'
import { getOrInstallCli } from './utilities/cliUtils'
import { pushIf } from './utilities/collectionUtils'
import { ChildProcess } from './utilities/processUtils'
import { findSshPath, getVscodeCliPath } from './utilities/pathFind'
import { IamClient } from './clients/iamClient'
import { IAM } from 'aws-sdk'
import { getIdeProperties } from './extensionUtilities'
import { pathFinder } from './utilities/pathFinder'

const policyAttachDelay = 5000

Expand All @@ -30,7 +30,7 @@ export interface MissingTool {
readonly reason?: string
}

const minimumSsmActions = [
export const minimumSsmActions = [
'ssmmessages:CreateControlChannel',
'ssmmessages:CreateDataChannel',
'ssmmessages:OpenControlChannel',
Expand Down Expand Up @@ -139,7 +139,7 @@ async function ensureSsmCli() {
}

export async function ensureTools() {
const [vsc, ssh, ssm] = await Promise.all([getVscodeCliPath(), findSshPath(), ensureSsmCli()])
const [vsc, ssh, ssm] = await Promise.all([pathFinder.getVscodeCliPath(), pathFinder.findSshPath(), ensureSsmCli()])

const missing: MissingTool[] = []
pushIf(missing, vsc === undefined, { name: 'code' })
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/shared/sam/cli/samCliLocator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import { getLogger, Logger } from '../../logger'
import { SamCliInfoInvocation } from './samCliInfo'
import { DefaultSamCliValidator, SamCliValidatorContext, SamCliVersionValidation } from './samCliValidator'
import { PerfLog } from '../../logger/perfLogger'
import { tryRun } from '../../utilities/pathFind'
import { PathFinder } from '../../utilities/pathFinder'

export class SamCliLocationProvider {
private static samCliLocator: BaseSamCliLocator | undefined
protected static cachedSamLocation: { path: string; version: string } | undefined

/** Checks that the given `sam` actually works by invoking `sam --version`. */
private static async isValidSamLocation(samPath: string) {
return await tryRun(samPath, ['--version'], 'no', 'SAM CLI')
return await PathFinder.tryRun(samPath, ['--version'], 'no', 'SAM CLI')
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/shared/sam/debugger/typescriptSamDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { findParentProjectFile } from '../../utilities/workspaceUtils'
import { DefaultSamLocalInvokeCommand, waitForDebuggerMessages } from '../cli/samCliLocalInvoke'
import { runLambdaFunction, waitForPort } from '../localLambdaRunner'
import { SamLaunchRequestArgs } from './awsSamDebugger'
import { findTypescriptCompiler } from '../../utilities/pathFind'
import { pathFinder } from '../../utilities/pathFinder'
import fs from '../../fs/fs'

const tsConfigFile = 'aws-toolkit-tsconfig.json'
Expand Down Expand Up @@ -209,7 +209,7 @@ async function compileTypeScript(config: SamLaunchRequestArgs): Promise<void> {
config.invokeTarget.lambdaHandler = pathutil.normalizeSeparator(tsLambdaHandler)
getLogger().info(`Resolved compiled lambda handler to ${tsLambdaHandler}`)

const tsc = await findTypescriptCompiler()
const tsc = await pathFinder.findTypescriptCompiler()
if (!tsc) {
throw new Error('TypeScript compiler "tsc" not found in node_modules/ or the system.')
}
Expand Down
182 changes: 0 additions & 182 deletions packages/core/src/shared/utilities/pathFind.ts

This file was deleted.

Loading
Loading