mirror of
https://github.com/stablyai/orca.git
synced 2026-10-19 00:03:20 +00:00
* fix(ssh): probe npm via prepended PATH, not colocated with node (#9165) The remote Node/npm toolchain gate invoked npm by its absolute path <nodeBinDir>/npm (POSIX) / npm.cmd (Windows, behind a Test-Path colocation check). But deploy (commandWithNodePath) runs bare `npm` with nodeBinDir merely prepended to PATH, so npm can resolve from anywhere on PATH. A host whose only resolvable node has npm elsewhere on PATH (e.g. node symlinked into a dir without npm) deployed fine on v1.4.144, but after upgrade the candidate is rejected with no fallback → SSH/relay connection fails to establish. Make the probe resolve npm exactly the way deploy does — bare `npm --version` under the same prepended PATH — so it still confirms npm is runnable (the #8450 concern) without requiring colocation. Windows now prepends the backslash-form dir (matching deploy) so bare-command PATH lookup resolves reliably. * test(ssh): cover split Node npm PATH resolution
50 lines
2.0 KiB
TypeScript
50 lines
2.0 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
buildPosixNodeToolchainProbe,
|
|
buildWindowsNodeToolchainProbe,
|
|
nodeToolchainVersionsMeetRequirements
|
|
} from './ssh-remote-node-toolchain-probe'
|
|
|
|
describe('remote Node/npm toolchain probe', () => {
|
|
it('probes bare npm with the selected POSIX Node directory prepended to PATH', () => {
|
|
// Deploy runs bare `npm` under the same prepended PATH, so accept npm from
|
|
// anywhere on PATH rather than requiring it colocated with node (#9165).
|
|
expect(buildPosixNodeToolchainProbe('/home/u/My Node/bin/node')).toBe(
|
|
"printf '%s\\n' '__ORCA_NODE_VERSION__' && '/home/u/My Node/bin/node' --version && " +
|
|
"printf '%s\\n' '__ORCA_NPM_VERSION__' && PATH='/home/u/My Node/bin':$PATH npm --version"
|
|
)
|
|
})
|
|
|
|
it('probes bare npm with the selected Windows Node directory prepended to PATH', () => {
|
|
const probe = buildWindowsNodeToolchainProbe('C:/Program Files/nodejs/node.exe')
|
|
|
|
expect(probe).not.toContain('Test-Path')
|
|
expect(probe).toContain("$env:PATH = 'C:\\Program Files\\nodejs' + ';' + $env:PATH")
|
|
expect(probe).toContain("& 'C:/Program Files/nodejs/node.exe' --version")
|
|
expect(probe).toContain('& npm --version')
|
|
})
|
|
|
|
it('requires marked, parseable Node and npm versions', () => {
|
|
expect(
|
|
nodeToolchainVersionsMeetRequirements(
|
|
'banner\n__ORCA_NODE_VERSION__\nv22.22.0\n__ORCA_NPM_VERSION__\n11.13.0\n'
|
|
)
|
|
).toBe(true)
|
|
expect(
|
|
nodeToolchainVersionsMeetRequirements(
|
|
'__ORCA_NODE_VERSION__\nv22.22.0\n__ORCA_NPM_VERSION__\nshim did nothing\n'
|
|
)
|
|
).toBe(false)
|
|
expect(
|
|
nodeToolchainVersionsMeetRequirements(
|
|
'__ORCA_NODE_VERSION__\nv16.20.2\n__ORCA_NPM_VERSION__\n10.8.2\n'
|
|
)
|
|
).toBe(false)
|
|
})
|
|
|
|
it('accepts legacy Node-only output from existing proxy integrations', () => {
|
|
expect(nodeToolchainVersionsMeetRequirements('v18.0.0\n')).toBe(true)
|
|
expect(nodeToolchainVersionsMeetRequirements('v16.20.2\n')).toBe(false)
|
|
})
|
|
})
|