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

39 lines
2.1 KiB
JavaScript

// The source-development composition (`pnpm run build`); the compiler consumes prepared inputs.
import { execFileSync } from 'node:child_process'
import { cpSync } from 'node:fs'
import { join, resolve } from 'node:path'
import { parseArgs } from 'node:util'
import { isMain, repoRoot } from '../../../scripts/build/frontend-common.mjs'
import { nativeInputsComplete } from './prepared-native-deps.mjs'
export function buildSourceDesktop({ source = repoRoot, icons, run = execFileSync } = {}) {
source = resolve(source)
const app = join(source, 'apps/desktop')
const step = (script, args = []) => run(process.execPath, [join(source, script), ...args], { cwd: app, stdio: 'inherit' })
step('apps/desktop/scripts/assert-root-install.mjs')
// Stamp before the flavored icons land: they overwrite committed files, and
// the stamp's git check would then call the checkout dirty.
step('apps/desktop/scripts/write-build-stamp.mjs')
// Default-brand icons are committed; only flavored release builds pass --icons.
icons = resolve(icons ?? source)
if (icons !== source) {
// electron-builder consumes packaging artwork in the workspace. Copy the
// prepared pixels; do not create another Python environment to redraw them.
cpSync(join(icons, 'apps/desktop/assets'), join(app, 'assets'), { recursive: true })
}
// locales/_keys.desktop.json is a committed artifact (i18n-keys.test.mjs pins it to en.ts);
// the build must not write into the checkout — a dirty tree breaks `hermes update`.
// The native inputs carry their own receipt (inputs identity + tree digest): restaging the
// same sources recompiles two universal helpers for identical bytes on every update.
const nativeDeps = join(app, 'build/native-deps')
if (!nativeInputsComplete({ source, nativeDeps })) step('apps/desktop/scripts/stage-native-deps.mjs')
step('scripts/build/desktop.mjs', ['--source', source, '--icons', icons,
'--stamp', join(app, 'build/install-stamp.json'), '--native-deps', nativeDeps, '--out', join(app, 'dist')])
}
if (isMain(import.meta.url)) {
const { values } = parseArgs({ options: { icons: { type: 'string' } } })
buildSourceDesktop(values)
}