Files
hermes-agent/apps/desktop/e2e/electron-binary.unit.test.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

43 lines
1.8 KiB
TypeScript

import * as path from 'node:path'
import { describe, expect, it } from 'vitest'
import { electronDistCandidates, pathLookupCommand } from './electron-binary'
// Platform is a parameter everywhere below rather than read from
// process.platform, so the Windows rules are pinned on the Linux CI runner too.
// Reading the real platform would leave every Windows-only rule untested.
describe('electronDistCandidates', () => {
const desktop = path.join('repo', 'apps', 'desktop')
const repo = 'repo'
it('probes each root in the order given', () => {
// The nearest package comes first: probing only the repo root is what made
// the suite refuse to start on a tree whose electron lives in the desktop
// workspace, where pnpm links it.
expect(electronDistCandidates([desktop, repo], 'linux')).toEqual([
path.join(desktop, 'node_modules', 'electron', 'dist', 'electron'),
path.join(repo, 'node_modules', 'electron', 'dist', 'electron'),
])
})
it('carries the platform binary name into every candidate', () => {
// A bare `electron` file never exists in a Windows dist, so a probe built
// from a hardcoded name cannot match there no matter which root it walks.
for (const candidate of electronDistCandidates([desktop, repo], 'win32')) {
expect(path.basename(candidate)).toBe('electron.exe')
}
})
})
describe('pathLookupCommand', () => {
it('uses where on Windows and which elsewhere', () => {
// `which` is not a command on Windows; spawning it unconditionally made the
// PATH fallback fail for a reason unrelated to whether electron is on PATH.
expect(pathLookupCommand('win32')).toBe('where')
expect(pathLookupCommand('linux')).toBe('which')
expect(pathLookupCommand('darwin')).toBe('which')
})
})