Dependency acquisition during packaging left native wheels and packager inputs outside the pre-build cache save. Compose PM and existing providers into a preparation phase, then require builds to consume admitted inputs. Share native preparation with PM Bundle. Keep path-bound environments and signing outputs separate from reusable caches. Use read-only cache tokens for commit builds and preserve the one-command local build path. Verify pinned tools through PM, probe PTYs under the prepared Electron, and supply dmgbuild through a build-only PM package. Resolve bundled tool stores from their payload manifest so relocation preserves discovery. Validation: focused Python and JS tests, checkJs, Ruff, Windows checks, anti-slop, cache relocation, and network-denied Linux AppImage builds. Relocated runtime smoke passed with NixOS host libraries supplied. Native Windows/macOS signing and live GitHub cache behavior remain untested.
27 lines
1.2 KiB
JavaScript
27 lines
1.2 KiB
JavaScript
import fs from 'node:fs'
|
|
import path from 'node:path'
|
|
import { runPython } from '../../../scripts/build/python.mjs'
|
|
|
|
/**
|
|
* PM supplies the complete vendor tree, including the diagnostic hook's Python.
|
|
* Source convenience uses the same Python entrypoint as other build helpers.
|
|
* @param {{ source: string, out: string, cache: string, binary?: string }} options
|
|
* @returns {string}
|
|
*/
|
|
export function prepareDmgbuild({ source, out, cache, binary }) {
|
|
if (!binary) {
|
|
binary = String(runPython([path.join(import.meta.dirname, 'prepare_dmgbuild.py'),
|
|
'--out', path.join(cache, 'pm-tools'), '--cache', cache],
|
|
{ cwd: source, encoding: 'utf8', stdio: ['ignore', 'pipe', 'inherit'] })).trim()
|
|
}
|
|
const vendor = path.dirname(binary)
|
|
if (path.basename(binary) !== 'dmgbuild' || !fs.existsSync(binary) ||
|
|
!fs.statSync(binary).isFile() || !fs.existsSync(path.join(vendor, 'python/bin/python3'))) {
|
|
throw new Error(`PM dmgbuild launcher or paired Python is missing: ${binary}`)
|
|
}
|
|
const destination = path.join(out, 'dmgbuild')
|
|
fs.rmSync(destination, { recursive: true, force: true })
|
|
fs.cpSync(vendor, destination, { recursive: true, verbatimSymlinks: true })
|
|
return path.join(destination, 'dmgbuild')
|
|
}
|