Files
hermes-agent/apps/desktop/vitest.hermes-python.ts
Maciej Lisiewski 7062229090 chore(js): switch the workspaces from npm to pnpm
pnpm 12.15.0 (native executable) installs every JS workspace from one
pnpm-lock.yaml, imported from package-lock.json with the same resolved
versions. website/, the WhatsApp bridge and the photon sidecar stay separate
npm projects.

Configuration moves from .npmrc and the root manifest into
pnpm-workspace.yaml: the 14-day minimumReleaseAge and its excludes,
overrides, allowBuilds (the old allowScripts set, with strictDepBuilds
failing any unlisted build script), engineStrict, sideEffectsCache: false
(in-place rebuilds must not write into the store) and
verifyDepsBeforeRun: false (a `pnpm run` never installs).

The pnpm version is pinned in pm/lock.json and in root devEngines.
pmOnFail: ignore keeps that pin out of pnpm-lock.yaml: a leading pin
document makes osv-scanner read zero packages. scripts/build/node-deps.mjs
enforces the exact version instead, and every lock reader refuses a
multi-document lock. A root preinstall refuses `npm install`; devEngines
onFail is warn so npx (MCP servers, the tsc linter) keeps working inside
the checkout.

User-machine installs run --frozen-lockfile --trust-lockfile (release age is
checked when locking, in CI, not per user). node-deps removes npm-era
node_modules trees before the first pnpm install. Nix builds the store with
fetchPnpmDeps and a hash file that CI checks.
2026-11-06 04:08:24 +01:00

33 lines
1.2 KiB
TypeScript

/**
* HERMES_PYTHON for the electron contracts that drive real hermes_cli / pm code
* (mac-sign, source-backend, checkout-source). CI exports the PM test
* environment's interpreter; a developer's plain `pnpm exec vitest` does not, and the
* PATH python3 lacks the application dependencies. Resolve the checkout's test
* interpreter the way scripts/run_tests.sh does. Workers inherit process.env.
*/
import { execFileSync } from 'node:child_process'
import path from 'node:path'
const repo = path.resolve(import.meta.dirname, '../..')
export default function setup(): void {
if (process.env.HERMES_PYTHON || process.platform === 'win32') {
return
}
try {
const python = execFileSync(
'bash',
[path.join(repo, 'scripts', 'run-in-hermes-env'), 'sh', '-c', 'printf %s "$__HERMES_TEST_PYTHON"'],
{ cwd: repo, encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit'] }
)
if (python) {
process.env.HERMES_PYTHON = python
}
} catch (error: unknown) {
// Electron tests that need no Python still run; only the contracts above fail, naming HERMES_PYTHON.
console.warn(`vitest: could not resolve the Hermes test interpreter: ${String(error)}`)
}
}