Files
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

35 lines
1.6 KiB
Python

"""Bundle commands run the prepared pnpm, including Nix's shell wrapper."""
import json
import os
from pathlib import Path
import shutil
import subprocess
from scripts.bundles.desktop import pnpm_command
def test_bundle_pnpm_runs_workspace_from_unrelated_directory(tmp_path):
node = shutil.which("node")
assert node, "the build acceptance lane must provide Node/pnpm"
workspace = tmp_path / "workspace with spaces"
workspace.mkdir()
(workspace / "package.json").write_text(json.dumps({
"name": "bundle-command-fixture", "version": "1.0.0",
"scripts": {"build": "node probe.cjs"},
}), encoding="utf-8")
(workspace / "probe.cjs").write_text(
"console.log(JSON.stringify({args:process.argv.slice(2),pnpm:process.env.npm_execpath}));"
"process.exitCode=7", encoding="utf-8")
env = {key: value for key, value in os.environ.items()
if key.lower() != "npm_execpath"}
env.update(HOME=str(tmp_path), pnpm_config_store_dir=str(tmp_path / "store"),
pnpm_config_cache_dir=str(tmp_path / "cache"), pnpm_config_state_dir=str(tmp_path / "state"),
pnpm_config_offline="true")
result = subprocess.run([*pnpm_command(node), "--dir", str(workspace),
"run", "--silent", "build", "two words", "$(literal)"],
cwd=tmp_path, env=env, capture_output=True, text=True, timeout=30, check=False)
assert result.returncode == 7, result.stdout + result.stderr
child = json.loads(result.stdout)
assert child["args"] == ["two words", "$(literal)"]
assert "pnpm" in Path(child["pnpm"]).name