@powerhousedao/desktop 6.2.3-dev.99 → 6.3.0-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{bundle-backend-CvUS8-oc.mjs → bundle-backend-Bndax_Fd.mjs} +275 -14
- package/dist/bundle-backend-Bndax_Fd.mjs.map +1 -0
- package/dist/index.d.mts +89 -6
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/dist/local-key/local-key.mjs +1 -1
- package/dist/runner.d.mts.map +1 -1
- package/dist/runner.mjs +24 -8
- package/dist/runner.mjs.map +1 -1
- package/dist/sign-in/sign-in.js +92 -92
- package/package.json +4 -4
- package/dist/bundle-backend-CvUS8-oc.mjs.map +0 -1
package/dist/runner.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { I as releaseReport, M as collectRelease, O as loadAppJson, P as releaseBaseUrl, S as pluginPackagesOf, a as shellEnv, b as projectShell, c as fetchNodeSidecar, f as runTauriIcon, g as ICON_SOURCE, h as tauriSpawn, i as resolveShell, m as tauriBundlesForHost, n as launchShell, p as tauriBuildArgs, s as detectToolchain, t as bundleBackend, u as preflightOrThrow, v as UNSIGNED_BUILD_CONF, w as APP_JSON_FILE, x as bundleStack, y as bundleVersion } from "./bundle-backend-Bndax_Fd.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import fs from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
@@ -288,14 +288,17 @@ async function build(host, ctx) {
|
|
|
288
288
|
if (mode === "generated") {
|
|
289
289
|
const hostDir = hostDirOf(host, ctx);
|
|
290
290
|
const app = loadAppJson(hostDir);
|
|
291
|
+
const version = projectVersion(ctx.projectRoot);
|
|
291
292
|
const { shellDir, binName, changed } = projectShell({
|
|
292
293
|
hostDir,
|
|
293
294
|
app,
|
|
294
295
|
connectPort: port,
|
|
295
|
-
version
|
|
296
|
+
version
|
|
296
297
|
});
|
|
297
298
|
const tauri = preflightOrThrow(detectToolchain(ctx.projectRoot), host.name);
|
|
298
299
|
provisionShell(shellDir, tauri, changed);
|
|
300
|
+
const signingKey = Boolean(process.env.TAURI_SIGNING_PRIVATE_KEY);
|
|
301
|
+
const releaseUrl = app.updates && signingKey ? releaseBaseUrl(app.updates, version, ctx.env) : null;
|
|
299
302
|
console.log(`[${host.name}] staging the stack into ${shellDir}…`);
|
|
300
303
|
const staged = bundleStack({
|
|
301
304
|
projectRoot: ctx.projectRoot,
|
|
@@ -313,13 +316,26 @@ async function build(host, ctx) {
|
|
|
313
316
|
console.log(`[${host.name}] stack staged at ${staged.stackDir}${staged.vendored ? " (ph-run vendored)" : ""}.`);
|
|
314
317
|
const bundles = tauriBundlesForHost();
|
|
315
318
|
console.log(`[${host.name}] building '${binName}' (${tauri.via}: cargo tauri build --bundles ${bundles.join(",")})…`);
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
319
|
+
if (app.updates && !signingKey) console.warn(`[${host.name}] app.json turns updates on, but TAURI_SIGNING_PRIVATE_KEY is not set: this build is not signed, so it cannot be offered as an update. Set the key to build a release.`);
|
|
320
|
+
const started = Date.now();
|
|
321
|
+
const result = spawnSyncTauri(tauri, tauriBuildArgs(bundles, {
|
|
322
|
+
on: Boolean(app.updates),
|
|
323
|
+
signingKey,
|
|
324
|
+
unsignedConf: UNSIGNED_BUILD_CONF
|
|
325
|
+
}), shellDir);
|
|
326
|
+
const bundleDir = path.join(shellDir, "target", "release", "bundle");
|
|
327
|
+
if (app.updates && signingKey) {
|
|
328
|
+
const release = collectRelease({
|
|
329
|
+
bundleDir,
|
|
330
|
+
productName: app.productName,
|
|
331
|
+
version: bundleVersion(version),
|
|
332
|
+
baseUrl: releaseUrl,
|
|
333
|
+
since: started
|
|
334
|
+
});
|
|
335
|
+
for (const line of releaseReport(release, releaseUrl)) console.log(`[${host.name}] ${line}`);
|
|
336
|
+
}
|
|
321
337
|
if (result !== 0) throw new Error(`hosts/${host.name}: \`cargo tauri build\` failed (exit ${result}).`);
|
|
322
|
-
console.log(`[${host.name}] desktop app built — installers under ${
|
|
338
|
+
console.log(`[${host.name}] desktop app built — installers under ${bundleDir}.`);
|
|
323
339
|
return;
|
|
324
340
|
}
|
|
325
341
|
if (mode === "none") {
|
package/dist/runner.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.mjs","names":[],"sources":["../src/member-files.ts","../src/runner.ts"],"sourcesContent":["import { CONNECT_RUNNER, loadHost } from \"@powerhousedao/host-core\";\nimport { isPassthroughImageRef } from \"@powerhousedao/shared/connect/image-ref\";\n\ntype Drives = { icon?: unknown }[] | undefined;\n\n/** The project files the members' drive declarations name as icons. A server\n * reads them from the project root when it seeds its drives, so a stack has to\n * carry them. Connect's are compiled into its build. */\nexport async function memberProjectFiles(\n host: {\n children: Record<string, { host: string; reactor?: { drives?: unknown } }>;\n },\n projectRoot: string,\n): Promise<string[]> {\n const files = new Set<string>();\n for (const wrapper of Object.values(host.children)) {\n const member = await loadHost(projectRoot, wrapper.host);\n if (member.host.runner.module === CONNECT_RUNNER) continue;\n const declared = [\n ...((member.host.reactor?.drives as Drives) ?? []),\n ...((wrapper.reactor?.drives as Drives) ?? []),\n ];\n for (const { icon } of declared) {\n if (typeof icon === \"string\" && !isPassthroughImageRef(icon)) {\n files.add(icon);\n }\n }\n }\n return [...files].sort();\n}\n","import { spawn, spawnSync, type ChildProcess } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport {\n CONNECT_RUNNER,\n compoundWiringSchema,\n getVerb,\n loadHost,\n refineStartOrder,\n resolveRunnerModule,\n validateHost,\n type RunnerContext,\n type RunnerHandle,\n type PluginEntryData,\n} from \"@powerhousedao/host-core\";\nimport {\n defineHostSchemas,\n HOST_NAME_MESSAGE,\n hostNameSchema,\n} from \"@powerhousedao/host-core/schema\";\nimport { memberProjectFiles } from \"./member-files.js\";\nimport { z } from \"zod\";\nimport { APP_JSON_FILE, loadAppJson } from \"./app-json.js\";\nimport { bundleBackend } from \"./bundle-backend.js\";\nimport { bundleStack, pluginPackagesOf } from \"./bundle-stack.js\";\nimport { ICON_SOURCE, projectShell } from \"./shell-project.js\";\nimport {\n detectToolchain,\n fetchNodeSidecar,\n preflightOrThrow,\n runTauriIcon,\n tauriBundlesForHost,\n tauriSpawn,\n type TauriCommand,\n} from \"./shell-toolchain.js\";\nimport { launchShell, resolveShell, shellEnv } from \"./shell.js\";\n\n/**\n * @powerhousedao/desktop/runner.\n *\n * - `run`/`serve`: the headless stack — byte-identical delegation to\n * host-core's generic compound (phase-3 semantics unchanged).\n * - `dev`: the NATIVE window. Mode 1 (phase 7) is the default — a builder\n * ships under THEIR identity by editing `hosts/<host>/app.json` and never\n * writing Rust: the runner projects app.json into a generated `tauri-shell/`\n * that depends on the published `ph-desktop-shell` crate, provisions the\n * native toolchain's compile-time inputs (node sidecar + icon set), and runs\n * `cargo tauri dev`. An explicit `runner.shell.project` (or PH_DESKTOP_SHELL)\n * still selects a prebuilt/hand-maintained shell instead.\n * - `build`: the PACKAGING verb — members' builds (where exported), then the\n * shippable stack staged into the shell + `cargo tauri build` with\n * host-appropriate installer targets (nsis / app+dmg / deb+appimage).\n *\n * The native toolchain is required ONLY for dev/build; a missing cargo or\n * Tauri CLI fails with install guidance (see shell-toolchain). `ph run <host>`\n * (headless) needs none of it.\n */\n\nexport const kind = \"compound\";\n\n/** The verbs this runner exports (`shellMode` is a helper). */\nexport const verbs = [\"run\", \"serve\", \"dev\", \"build\"] as const;\n\n/** `runner.shell`: a prebuilt or hand-maintained shell (mode 2). Mirrors\n * `ShellOptions` (shell.ts); a type test pins the two together. */\nexport const shellOptionsSchema = z.strictObject({\n /** Path to a ph-win-desktop checkout (absolute or project-relative). */\n project: z.string().min(1).optional(),\n window: z\n .strictObject({\n title: z.string().optional(),\n width: z.number().int().positive().optional(),\n height: z.number().int().positive().optional(),\n })\n .optional(),\n tray: z.boolean().optional(),\n fileAssociations: z.array(z.string().min(1)).optional(),\n});\n\n/**\n * The desktop host, from one definition in two forms: DECLARED (what host.js\n * authors write) and RESOLVED (what the verbs receive). The runner adds no\n * token-able fields of its own; the forms differ in host-core's base blocks\n * (member wrappers' reactor URLs and the like).\n */\nconst schemas = defineHostSchemas((base) => {\n /** The desktop runner's own `runner` options, on top of the common base. */\n const desktopRunnerOptionsSchema = base.runnerBaseSchema\n .extend({\n shell: shellOptionsSchema.optional(),\n /** build: vendor ph-run into the staged stack (default true). */\n vendorStack: z.boolean().optional(),\n /** build: the ph-run version/tag to vendor (default: the project's\n * ph-cli version, else \"dev\"). */\n phCliVersion: z.string().min(1).optional(),\n /** build: full install spec override (e.g. a pnpm-pack tarball path)\n * for a ph-run not yet on the registry. */\n phCliSpec: z.string().min(1).optional(),\n /** build: fold the vendored stack into a few hundred files with\n * Rolldown, or set PH_DESKTOP_BUNDLE_BACKEND=1. Off by default until an\n * installed build has proven it. */\n bundleBackend: z.boolean().optional(),\n })\n .strict();\n\n /** The generic compound's wiring config plus the shell and packaging\n * options. Extend the unrefined base, refine last (zod refuses to extend\n * a refined object). */\n return base.compoundHostSchema\n .extend({\n runner: desktopRunnerOptionsSchema,\n config: compoundWiringSchema.optional(),\n })\n .superRefine(refineStartOrder);\n});\n\n/** Declared form: what a host file may contain before resolution. */\nexport const declaredHostSchema = schemas.declaredHostSchema;\n/** Resolved form: what the verbs receive (and `validateHost` checks). */\nexport const hostSchema = schemas.hostSchema;\n\n/** What a desktop host.js author writes. */\nexport type DesktopHostInput = z.input<typeof declaredHostSchema>;\n/** What the verbs receive. */\nexport type DesktopHost = z.output<typeof hostSchema>;\n\n/** The desktop compound produces nothing of its own: what its members\n * produce stays with the members (the compound's handles, the run record's\n * `members`). */\nexport const outputsSchema = z.strictObject({});\n\nexport type DesktopOutputs = z.infer<typeof outputsSchema>;\n\ndeclare global {\n interface PHHostRunners {\n \"@powerhousedao/desktop/runner\": {\n host: DesktopHostInput;\n outputs: DesktopOutputs;\n };\n }\n}\n\nexport type DesktopHandle = RunnerHandle<DesktopOutputs>;\n\nasync function compoundModule() {\n return import(\"@powerhousedao/host-core/runners/compound\");\n}\n\n/** hosts/<host>/ — where app.json lives and the generated shell is written. */\nfunction hostDirOf(\n host: Pick<DesktopHost, \"name\">,\n ctx: RunnerContext,\n): string {\n const hostsDir = path.resolve(ctx.projectRoot, \"hosts\");\n const dir = path.resolve(hostsDir, host.name);\n if (\n !hostNameSchema.safeParse(host.name).success ||\n path.dirname(dir) !== hostsDir\n ) {\n throw new Error(\n `\"${host.name}\" can't name a host folder. ${HOST_NAME_MESSAGE}`,\n );\n }\n return dir;\n}\n\n/** The connect member's port — the shell's readiness probe and window URL. */\nasync function connectPort(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<number> {\n for (const wrapper of Object.values(host.children)) {\n if (wrapper.host !== \"connect\") continue;\n if (wrapper.runner?.port !== undefined) return wrapper.runner.port;\n const member = await loadHost(ctx.projectRoot, wrapper.host);\n if (typeof member.host.runner.port === \"number\") {\n return member.host.runner.port;\n }\n }\n throw new Error(\n `hosts/${host.name}: no connect member with a resolvable runner.port — ` +\n `the shell needs it for its readiness probe and window URL.`,\n );\n}\n\nasync function startStack(\n host: DesktopHost,\n ctx: RunnerContext,\n verb: \"run\" | \"serve\",\n): Promise<DesktopHandle> {\n const compound = await compoundModule();\n const started = await compound[verb](host, ctx);\n return {\n outputs: outputsSchema.parse({}),\n // runCompound has already awaited every member's readiness.\n ready: Promise.resolve(),\n shutdown: started.shutdown,\n };\n}\n\nexport async function run(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<DesktopHandle> {\n return startStack(host, ctx, \"run\");\n}\n\n/** Every member at `serve`, as the generic compound's `serve`. */\nexport async function serve(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<DesktopHandle> {\n return startStack(host, ctx, \"serve\");\n}\n\nexport interface ShellHandle extends DesktopHandle {\n /** Resolves when the shell window exits — the runner's keep-alive. */\n exited: Promise<void>;\n}\n\n/** The handle for a launched shell process: `ready` once it is spawned. */\nfunction shellHandle(child: ChildProcess): ShellHandle {\n const exited = new Promise<void>((resolve) =>\n child.once(\"exit\", () => resolve()),\n );\n return {\n outputs: outputsSchema.parse({}),\n ready: Promise.resolve(),\n exited,\n shutdown: () => {\n try {\n child.kill();\n } catch {\n // already gone\n }\n return Promise.resolve();\n },\n };\n}\n\n/** Which shell backs this host's native window (D7.d source order):\n * an explicit `runner.shell.project`, else the app.json-generated shell,\n * else the PH_DESKTOP_SHELL escape hatch. */\nexport function shellMode(\n host: Pick<DesktopHost, \"name\" | \"runner\">,\n ctx: RunnerContext,\n): \"external-project\" | \"generated\" | \"external-env\" | \"none\" {\n if (host.runner.shell?.project) return \"external-project\";\n if (fs.existsSync(path.join(hostDirOf(host, ctx), APP_JSON_FILE))) {\n return \"generated\";\n }\n if (ctx.env.PH_DESKTOP_SHELL) return \"external-env\";\n return \"none\";\n}\n\n/** Fetch the node sidecar + (re)generate the icon set — both are tauri-build\n * COMPILE-TIME inputs (externalBin; icon.ico for the Windows resource),\n * confirmed against a live cargo check. Icon regen only when app-icon.png\n * changed or the set is absent. */\nfunction provisionShell(\n shellDir: string,\n tauri: TauriCommand,\n iconChanged: boolean,\n): void {\n fetchNodeSidecar(shellDir);\n const iconIco = path.join(shellDir, \"icons\", \"icon.ico\");\n if (iconChanged || !fs.existsSync(iconIco)) {\n runTauriIcon(tauri, shellDir, ICON_SOURCE);\n }\n}\n\n/** Spawn a `<tauri> <subcommand>` in the generated shell with the uniform-\n * runners env trio wired in. */\nfunction spawnTauri(\n tauri: TauriCommand,\n subcommand: string[],\n shellDir: string,\n envVars: Record<string, string>,\n) {\n const { command, args, shell } = tauriSpawn(tauri, subcommand);\n return spawn(command, args, {\n cwd: shellDir,\n env: { ...process.env, ...envVars },\n stdio: \"inherit\",\n shell,\n windowsHide: true,\n });\n}\n\nexport async function dev(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<ShellHandle> {\n const mode = shellMode(host, ctx);\n if (mode === \"none\") {\n throw new Error(\n `hosts/${host.name}: no desktop shell to run — add ${APP_JSON_FILE} ` +\n `(run \\`ph generate desktop-shell\\`) for a builder-owned identity, set ` +\n `runner.shell.project to a prebuilt shell, or export PH_DESKTOP_SHELL.`,\n );\n }\n\n const port = await connectPort(host, ctx);\n const envVars = shellEnv(ctx.projectRoot, port, ctx.env);\n\n if (mode === \"generated\") {\n const hostDir = hostDirOf(host, ctx);\n const app = loadAppJson(hostDir);\n const { shellDir, binName, changed } = projectShell({\n hostDir,\n app,\n connectPort: port,\n version: projectVersion(ctx.projectRoot),\n });\n const tauri = preflightOrThrow(detectToolchain(ctx.projectRoot), host.name);\n provisionShell(shellDir, tauri, changed);\n console.log(\n `[${host.name}] launching the generated desktop shell '${binName}' ` +\n `(${tauri.via}: cargo tauri dev) — stack via ph run ${host.name}, ` +\n `window at http://127.0.0.1:${port}/`,\n );\n return shellHandle(spawnTauri(tauri, [\"dev\"], shellDir, envVars));\n }\n\n // external-project / external-env: a prebuilt or hand-maintained shell.\n const options = host.runner;\n const shell = resolveShell(ctx.projectRoot, options.shell, ctx.env);\n console.log(\n `[${host.name}] launching the desktop shell ` +\n `(${shell.exe ? shell.exe : \"pnpm tauri dev\"}) — stack via ` +\n `ph run ${host.name}, window at http://127.0.0.1:${port}/`,\n );\n return shellHandle(launchShell(shell, envVars, options.shell));\n}\n\n/** Forward `build` to members that export it (packaging builds what is\n * buildable — unlike the generic compound's uniform fail-loud forwarding). */\nasync function buildMembers(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<void> {\n for (const [name, wrapper] of Object.entries(host.children)) {\n const member = await loadHost(ctx.projectRoot, wrapper.host);\n const specifier = member.host.runner.module;\n const runner = await resolveRunnerModule(ctx.projectRoot, specifier);\n const validated = validateHost(\n runner,\n specifier,\n member.host,\n `hosts/${wrapper.host}/host.js`,\n // build is one-shot: it needs no other member's outputs, so a declared\n // $output stays a token (as in the generic compound).\n { tokens: \"allow\" },\n );\n if (typeof runner.build !== \"function\") {\n console.log(\n `[${host.name}] build: ${name} (${wrapper.host}) exports no build — skipped (packaging builds what is buildable)`,\n );\n continue;\n }\n const fn = getVerb(runner, specifier, \"build\");\n console.log(`[${host.name}] build → ${name} (${wrapper.host})`);\n await fn(validated, {\n ...ctx,\n verb: \"build\",\n parent: { host: host.name, verb: ctx.verb },\n });\n }\n}\n\n/** What the members' plugins need, as the stack resolves them as the project\n * does, from its own node_modules. */\nasync function memberPluginPackages(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<string[]> {\n const projectRequire = createRequire(\n path.join(ctx.projectRoot, \"package.json\"),\n );\n const resolves = (specifier: string) => {\n try {\n projectRequire.resolve(specifier);\n return true;\n } catch {\n return false;\n }\n };\n const packages = new Set<string>();\n for (const wrapper of Object.values(host.children)) {\n const member = await loadHost(ctx.projectRoot, wrapper.host);\n // Connect's plugins are compiled into the build it serves, and all it reads\n // of them at run time is optional. Only a server loads any.\n if (member.host.runner.module === CONNECT_RUNNER) continue;\n const entries = member.host.runner.plugins as PluginEntryData[] | undefined;\n const where = `hosts/${wrapper.host}/host.js`;\n for (const name of pluginPackagesOf(entries ?? [], where, resolves)) {\n packages.add(name);\n }\n }\n return [...packages].sort();\n}\n\n/** The project's own version, which its installers carry. */\nfunction projectVersion(projectRoot: string): string | undefined {\n try {\n const manifest = JSON.parse(\n fs.readFileSync(path.join(projectRoot, \"package.json\"), \"utf8\"),\n ) as { version?: string };\n return manifest.version;\n } catch {\n return undefined;\n }\n}\n\n/** Folds a stack that was just vendored, when the host asks for that. */\nasync function bundleIfAsked(\n staged: { stackDir: string; vendored: boolean },\n asked: boolean | undefined,\n ctx: RunnerContext,\n): Promise<void> {\n if (!staged.vendored) return;\n if (!(asked ?? ctx.env.PH_DESKTOP_BUNDLE_BACKEND === \"1\")) return;\n await bundleBackend({\n stackDir: staged.stackDir,\n logger: (line) => console.log(line),\n });\n}\n\n/** PH_DESKTOP_LOCAL_PACKAGES: tarballs to vendor in place of the registry's\n * (a machine path, so an env var rather than a host-file option). */\nfunction localPackagesDir(ctx: RunnerContext): string | undefined {\n const dir = ctx.env.PH_DESKTOP_LOCAL_PACKAGES;\n return dir ? path.resolve(ctx.projectRoot, dir) : undefined;\n}\n\n/** build = members' builds + the shippable stack + the native installer. */\nexport async function build(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<void> {\n await buildMembers(host, ctx);\n\n const runnerOptions = host.runner;\n const mode = shellMode(host, ctx);\n const port = await connectPort(host, ctx);\n\n if (mode === \"generated\") {\n const hostDir = hostDirOf(host, ctx);\n const app = loadAppJson(hostDir);\n const { shellDir, binName, changed } = projectShell({\n hostDir,\n app,\n connectPort: port,\n version: projectVersion(ctx.projectRoot),\n });\n const tauri = preflightOrThrow(detectToolchain(ctx.projectRoot), host.name);\n provisionShell(shellDir, tauri, changed);\n\n console.log(`[${host.name}] staging the stack into ${shellDir}…`);\n const staged = bundleStack({\n projectRoot: ctx.projectRoot,\n shellProjectDir: shellDir,\n vendor: runnerOptions.vendorStack,\n phCliVersion: runnerOptions.phCliVersion,\n phCliSpec: runnerOptions.phCliSpec ?? ctx.env.PH_DESKTOP_PHCLI_SPEC,\n localPackagesDir: localPackagesDir(ctx),\n plugins: await memberPluginPackages(host, ctx),\n projectFiles: await memberProjectFiles(host, ctx.projectRoot),\n connectPort: port,\n // the generated shell lives under hosts/ — never stage it into itself\n excludeDirs: [shellDir],\n });\n await bundleIfAsked(staged, runnerOptions.bundleBackend, ctx);\n console.log(\n `[${host.name}] stack staged at ${staged.stackDir}` +\n `${staged.vendored ? \" (ph-run vendored)\" : \"\"}.`,\n );\n\n const bundles = tauriBundlesForHost();\n console.log(\n `[${host.name}] building '${binName}' (${tauri.via}: cargo tauri ` +\n `build --bundles ${bundles.join(\",\")})…`,\n );\n const result = spawnSyncTauri(\n tauri,\n [\"build\", \"--bundles\", bundles.join(\",\")],\n shellDir,\n );\n if (result !== 0) {\n throw new Error(\n `hosts/${host.name}: \\`cargo tauri build\\` failed (exit ${result}).`,\n );\n }\n console.log(\n `[${host.name}] desktop app built — installers under ` +\n `${path.join(shellDir, \"target\", \"release\", \"bundle\")}.`,\n );\n return;\n }\n\n // external-project / external-env: stage into the prebuilt shell (phase 6).\n if (mode === \"none\") {\n console.log(\n `[${host.name}] build: no shell configured — members built; shell ` +\n `packaging skipped (add ${APP_JSON_FILE} or set runner.shell.project).`,\n );\n return;\n }\n const shell = resolveShell(ctx.projectRoot, runnerOptions.shell, ctx.env);\n console.log(`[${host.name}] staging the stack into ${shell.projectDir}…`);\n const result = bundleStack({\n projectRoot: ctx.projectRoot,\n shellProjectDir: shell.projectDir,\n vendor: runnerOptions.vendorStack,\n phCliVersion: runnerOptions.phCliVersion,\n phCliSpec: runnerOptions.phCliSpec ?? ctx.env.PH_DESKTOP_PHCLI_SPEC,\n localPackagesDir: localPackagesDir(ctx),\n plugins: await memberPluginPackages(host, ctx),\n projectFiles: await memberProjectFiles(host, ctx.projectRoot),\n connectPort: port,\n });\n await bundleIfAsked(result, runnerOptions.bundleBackend, ctx);\n console.log(\n `[${host.name}] stack staged at ${result.stackDir}` +\n `${result.vendored ? \" (ph-run vendored)\" : \"\"} — the shell runs it with ` +\n `no environment (resources fallback).`,\n );\n}\n\n/** Synchronous `<tauri> <subcommand>` — build blocks until the installer is\n * produced. Returns the exit code. */\nfunction spawnSyncTauri(\n tauri: TauriCommand,\n subcommand: string[],\n shellDir: string,\n): number {\n const { command, args, shell } = tauriSpawn(tauri, subcommand);\n const r = spawnSync(command, args, {\n cwd: shellDir,\n stdio: \"inherit\",\n shell,\n windowsHide: true,\n });\n return r.status ?? 1;\n}\n"],"mappings":";;;;;;;;;;;;;AAQA,eAAsB,mBACpB,MAGA,aACmB;CACnB,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,WAAW,OAAO,OAAO,KAAK,QAAQ,GAAG;EAClD,MA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AAS,eACb,OACA;GAAC;GAAS;GAAa,QAAQ,KAAK,GAAG;EAAC,GACxC,QACF;EACA,IAAI,WAAW,GACb,MAAM,IAAI,MACR,SAAS,KAAK,KAAK,uCAAuC,OAAO,GACnE;EAEF,QAAQ,IACN,IAAI,KAAK,KAAK,yCACT,KAAK,KAAK,UAAU,UAAU,WAAW,QAAQ,EAAE,EAC1D;EACA;CACF;CAGA,IAAI,SAAS,QAAQ;EACnB,QAAQ,IACN,IAAI,KAAK,KAAK,6EACc,cAAc,+BAC5C;EACA;CACF;CACA,MAAM,QAAQ,aAAa,IAAI,aAAa,cAAc,OAAO,IAAI,GAAG;CACxE,QAAQ,IAAI,IAAI,KAAK,KAAK,2BAA2B,MAAM,WAAW,EAAE;CACxE,MAAM,SAAS,YAAY;EACzB,aAAa,IAAI;EACjB,iBAAiB,MAAM;EACvB,QAAQ,cAAc;EACtB,cAAc,cAAc;EAC5B,WAAW,cAAc,aAAa,IAAI,IAAI;EAC9C,kBAAkB,iBAAiB,GAAG;EACtC,SAAS,MAAM,qBAAqB,MAAM,GAAG;EAC7C,cAAc,MAAM,mBAAmB,MAAM,IAAI,WAAW;EAC5D,aAAa;CACf,CAAC;CACD,MAAM,cAAc,QAAQ,cAAc,eAAe,GAAG;CAC5D,QAAQ,IACN,IAAI,KAAK,KAAK,oBAAoB,OAAO,WACpC,OAAO,WAAW,uBAAuB,GAAG,+DAEnD;AACF;;;AAIA,SAAS,eACP,OACA,YACA,UACQ;CACR,MAAM,EAAE,SAAS,MAAM,UAAU,WAAW,OAAO,UAAU;CAO7D,OANU,UAAU,SAAS,MAAM;EACjC,KAAK;EACL,OAAO;EACP;EACA,aAAa;CACf,CACO,CAAC,CAAC,UAAU;AACrB"}
|
|
1
|
+
{"version":3,"file":"runner.mjs","names":[],"sources":["../src/member-files.ts","../src/runner.ts"],"sourcesContent":["import { CONNECT_RUNNER, loadHost } from \"@powerhousedao/host-core\";\nimport { isPassthroughImageRef } from \"@powerhousedao/shared/connect/image-ref\";\n\ntype Drives = { icon?: unknown }[] | undefined;\n\n/** The project files the members' drive declarations name as icons. A server\n * reads them from the project root when it seeds its drives, so a stack has to\n * carry them. Connect's are compiled into its build. */\nexport async function memberProjectFiles(\n host: {\n children: Record<string, { host: string; reactor?: { drives?: unknown } }>;\n },\n projectRoot: string,\n): Promise<string[]> {\n const files = new Set<string>();\n for (const wrapper of Object.values(host.children)) {\n const member = await loadHost(projectRoot, wrapper.host);\n if (member.host.runner.module === CONNECT_RUNNER) continue;\n const declared = [\n ...((member.host.reactor?.drives as Drives) ?? []),\n ...((wrapper.reactor?.drives as Drives) ?? []),\n ];\n for (const { icon } of declared) {\n if (typeof icon === \"string\" && !isPassthroughImageRef(icon)) {\n files.add(icon);\n }\n }\n }\n return [...files].sort();\n}\n","import { spawn, spawnSync, type ChildProcess } from \"node:child_process\";\nimport fs from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport path from \"node:path\";\nimport {\n CONNECT_RUNNER,\n compoundWiringSchema,\n getVerb,\n loadHost,\n refineStartOrder,\n resolveRunnerModule,\n validateHost,\n type RunnerContext,\n type RunnerHandle,\n type PluginEntryData,\n} from \"@powerhousedao/host-core\";\nimport {\n defineHostSchemas,\n HOST_NAME_MESSAGE,\n hostNameSchema,\n} from \"@powerhousedao/host-core/schema\";\nimport { memberProjectFiles } from \"./member-files.js\";\nimport { z } from \"zod\";\nimport { APP_JSON_FILE, loadAppJson } from \"./app-json.js\";\nimport { bundleBackend } from \"./bundle-backend.js\";\nimport { bundleStack, pluginPackagesOf } from \"./bundle-stack.js\";\nimport { collectRelease, releaseBaseUrl, releaseReport } from \"./release.js\";\nimport {\n bundleVersion,\n ICON_SOURCE,\n projectShell,\n UNSIGNED_BUILD_CONF,\n} from \"./shell-project.js\";\nimport {\n detectToolchain,\n fetchNodeSidecar,\n preflightOrThrow,\n runTauriIcon,\n tauriBuildArgs,\n tauriBundlesForHost,\n tauriSpawn,\n type TauriCommand,\n} from \"./shell-toolchain.js\";\nimport { launchShell, resolveShell, shellEnv } from \"./shell.js\";\n\n/**\n * @powerhousedao/desktop/runner.\n *\n * - `run`/`serve`: the headless stack — byte-identical delegation to\n * host-core's generic compound (phase-3 semantics unchanged).\n * - `dev`: the NATIVE window. Mode 1 (phase 7) is the default — a builder\n * ships under THEIR identity by editing `hosts/<host>/app.json` and never\n * writing Rust: the runner projects app.json into a generated `tauri-shell/`\n * that depends on the published `ph-desktop-shell` crate, provisions the\n * native toolchain's compile-time inputs (node sidecar + icon set), and runs\n * `cargo tauri dev`. An explicit `runner.shell.project` (or PH_DESKTOP_SHELL)\n * still selects a prebuilt/hand-maintained shell instead.\n * - `build`: the PACKAGING verb — members' builds (where exported), then the\n * shippable stack staged into the shell + `cargo tauri build` with\n * host-appropriate installer targets (nsis / app+dmg / deb+appimage).\n *\n * The native toolchain is required ONLY for dev/build; a missing cargo or\n * Tauri CLI fails with install guidance (see shell-toolchain). `ph run <host>`\n * (headless) needs none of it.\n */\n\nexport const kind = \"compound\";\n\n/** The verbs this runner exports (`shellMode` is a helper). */\nexport const verbs = [\"run\", \"serve\", \"dev\", \"build\"] as const;\n\n/** `runner.shell`: a prebuilt or hand-maintained shell (mode 2). Mirrors\n * `ShellOptions` (shell.ts); a type test pins the two together. */\nexport const shellOptionsSchema = z.strictObject({\n /** Path to a ph-win-desktop checkout (absolute or project-relative). */\n project: z.string().min(1).optional(),\n window: z\n .strictObject({\n title: z.string().optional(),\n width: z.number().int().positive().optional(),\n height: z.number().int().positive().optional(),\n })\n .optional(),\n tray: z.boolean().optional(),\n fileAssociations: z.array(z.string().min(1)).optional(),\n});\n\n/**\n * The desktop host, from one definition in two forms: DECLARED (what host.js\n * authors write) and RESOLVED (what the verbs receive). The runner adds no\n * token-able fields of its own; the forms differ in host-core's base blocks\n * (member wrappers' reactor URLs and the like).\n */\nconst schemas = defineHostSchemas((base) => {\n /** The desktop runner's own `runner` options, on top of the common base. */\n const desktopRunnerOptionsSchema = base.runnerBaseSchema\n .extend({\n shell: shellOptionsSchema.optional(),\n /** build: vendor ph-run into the staged stack (default true). */\n vendorStack: z.boolean().optional(),\n /** build: the ph-run version/tag to vendor (default: the project's\n * ph-cli version, else \"dev\"). */\n phCliVersion: z.string().min(1).optional(),\n /** build: full install spec override (e.g. a pnpm-pack tarball path)\n * for a ph-run not yet on the registry. */\n phCliSpec: z.string().min(1).optional(),\n /** build: fold the vendored stack into a few hundred files with\n * Rolldown, or set PH_DESKTOP_BUNDLE_BACKEND=1. Off by default until an\n * installed build has proven it. */\n bundleBackend: z.boolean().optional(),\n })\n .strict();\n\n /** The generic compound's wiring config plus the shell and packaging\n * options. Extend the unrefined base, refine last (zod refuses to extend\n * a refined object). */\n return base.compoundHostSchema\n .extend({\n runner: desktopRunnerOptionsSchema,\n config: compoundWiringSchema.optional(),\n })\n .superRefine(refineStartOrder);\n});\n\n/** Declared form: what a host file may contain before resolution. */\nexport const declaredHostSchema = schemas.declaredHostSchema;\n/** Resolved form: what the verbs receive (and `validateHost` checks). */\nexport const hostSchema = schemas.hostSchema;\n\n/** What a desktop host.js author writes. */\nexport type DesktopHostInput = z.input<typeof declaredHostSchema>;\n/** What the verbs receive. */\nexport type DesktopHost = z.output<typeof hostSchema>;\n\n/** The desktop compound produces nothing of its own: what its members\n * produce stays with the members (the compound's handles, the run record's\n * `members`). */\nexport const outputsSchema = z.strictObject({});\n\nexport type DesktopOutputs = z.infer<typeof outputsSchema>;\n\ndeclare global {\n interface PHHostRunners {\n \"@powerhousedao/desktop/runner\": {\n host: DesktopHostInput;\n outputs: DesktopOutputs;\n };\n }\n}\n\nexport type DesktopHandle = RunnerHandle<DesktopOutputs>;\n\nasync function compoundModule() {\n return import(\"@powerhousedao/host-core/runners/compound\");\n}\n\n/** hosts/<host>/ — where app.json lives and the generated shell is written. */\nfunction hostDirOf(\n host: Pick<DesktopHost, \"name\">,\n ctx: RunnerContext,\n): string {\n const hostsDir = path.resolve(ctx.projectRoot, \"hosts\");\n const dir = path.resolve(hostsDir, host.name);\n if (\n !hostNameSchema.safeParse(host.name).success ||\n path.dirname(dir) !== hostsDir\n ) {\n throw new Error(\n `\"${host.name}\" can't name a host folder. ${HOST_NAME_MESSAGE}`,\n );\n }\n return dir;\n}\n\n/** The connect member's port — the shell's readiness probe and window URL. */\nasync function connectPort(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<number> {\n for (const wrapper of Object.values(host.children)) {\n if (wrapper.host !== \"connect\") continue;\n if (wrapper.runner?.port !== undefined) return wrapper.runner.port;\n const member = await loadHost(ctx.projectRoot, wrapper.host);\n if (typeof member.host.runner.port === \"number\") {\n return member.host.runner.port;\n }\n }\n throw new Error(\n `hosts/${host.name}: no connect member with a resolvable runner.port — ` +\n `the shell needs it for its readiness probe and window URL.`,\n );\n}\n\nasync function startStack(\n host: DesktopHost,\n ctx: RunnerContext,\n verb: \"run\" | \"serve\",\n): Promise<DesktopHandle> {\n const compound = await compoundModule();\n const started = await compound[verb](host, ctx);\n return {\n outputs: outputsSchema.parse({}),\n // runCompound has already awaited every member's readiness.\n ready: Promise.resolve(),\n shutdown: started.shutdown,\n };\n}\n\nexport async function run(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<DesktopHandle> {\n return startStack(host, ctx, \"run\");\n}\n\n/** Every member at `serve`, as the generic compound's `serve`. */\nexport async function serve(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<DesktopHandle> {\n return startStack(host, ctx, \"serve\");\n}\n\nexport interface ShellHandle extends DesktopHandle {\n /** Resolves when the shell window exits — the runner's keep-alive. */\n exited: Promise<void>;\n}\n\n/** The handle for a launched shell process: `ready` once it is spawned. */\nfunction shellHandle(child: ChildProcess): ShellHandle {\n const exited = new Promise<void>((resolve) =>\n child.once(\"exit\", () => resolve()),\n );\n return {\n outputs: outputsSchema.parse({}),\n ready: Promise.resolve(),\n exited,\n shutdown: () => {\n try {\n child.kill();\n } catch {\n // already gone\n }\n return Promise.resolve();\n },\n };\n}\n\n/** Which shell backs this host's native window (D7.d source order):\n * an explicit `runner.shell.project`, else the app.json-generated shell,\n * else the PH_DESKTOP_SHELL escape hatch. */\nexport function shellMode(\n host: Pick<DesktopHost, \"name\" | \"runner\">,\n ctx: RunnerContext,\n): \"external-project\" | \"generated\" | \"external-env\" | \"none\" {\n if (host.runner.shell?.project) return \"external-project\";\n if (fs.existsSync(path.join(hostDirOf(host, ctx), APP_JSON_FILE))) {\n return \"generated\";\n }\n if (ctx.env.PH_DESKTOP_SHELL) return \"external-env\";\n return \"none\";\n}\n\n/** Fetch the node sidecar + (re)generate the icon set — both are tauri-build\n * COMPILE-TIME inputs (externalBin; icon.ico for the Windows resource),\n * confirmed against a live cargo check. Icon regen only when app-icon.png\n * changed or the set is absent. */\nfunction provisionShell(\n shellDir: string,\n tauri: TauriCommand,\n iconChanged: boolean,\n): void {\n fetchNodeSidecar(shellDir);\n const iconIco = path.join(shellDir, \"icons\", \"icon.ico\");\n if (iconChanged || !fs.existsSync(iconIco)) {\n runTauriIcon(tauri, shellDir, ICON_SOURCE);\n }\n}\n\n/** Spawn a `<tauri> <subcommand>` in the generated shell with the uniform-\n * runners env trio wired in. */\nfunction spawnTauri(\n tauri: TauriCommand,\n subcommand: string[],\n shellDir: string,\n envVars: Record<string, string>,\n) {\n const { command, args, shell } = tauriSpawn(tauri, subcommand);\n return spawn(command, args, {\n cwd: shellDir,\n env: { ...process.env, ...envVars },\n stdio: \"inherit\",\n shell,\n windowsHide: true,\n });\n}\n\nexport async function dev(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<ShellHandle> {\n const mode = shellMode(host, ctx);\n if (mode === \"none\") {\n throw new Error(\n `hosts/${host.name}: no desktop shell to run — add ${APP_JSON_FILE} ` +\n `(run \\`ph generate desktop-shell\\`) for a builder-owned identity, set ` +\n `runner.shell.project to a prebuilt shell, or export PH_DESKTOP_SHELL.`,\n );\n }\n\n const port = await connectPort(host, ctx);\n const envVars = shellEnv(ctx.projectRoot, port, ctx.env);\n\n if (mode === \"generated\") {\n const hostDir = hostDirOf(host, ctx);\n const app = loadAppJson(hostDir);\n const { shellDir, binName, changed } = projectShell({\n hostDir,\n app,\n connectPort: port,\n version: projectVersion(ctx.projectRoot),\n });\n const tauri = preflightOrThrow(detectToolchain(ctx.projectRoot), host.name);\n provisionShell(shellDir, tauri, changed);\n console.log(\n `[${host.name}] launching the generated desktop shell '${binName}' ` +\n `(${tauri.via}: cargo tauri dev) — stack via ph run ${host.name}, ` +\n `window at http://127.0.0.1:${port}/`,\n );\n return shellHandle(spawnTauri(tauri, [\"dev\"], shellDir, envVars));\n }\n\n // external-project / external-env: a prebuilt or hand-maintained shell.\n const options = host.runner;\n const shell = resolveShell(ctx.projectRoot, options.shell, ctx.env);\n console.log(\n `[${host.name}] launching the desktop shell ` +\n `(${shell.exe ? shell.exe : \"pnpm tauri dev\"}) — stack via ` +\n `ph run ${host.name}, window at http://127.0.0.1:${port}/`,\n );\n return shellHandle(launchShell(shell, envVars, options.shell));\n}\n\n/** Forward `build` to members that export it (packaging builds what is\n * buildable — unlike the generic compound's uniform fail-loud forwarding). */\nasync function buildMembers(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<void> {\n for (const [name, wrapper] of Object.entries(host.children)) {\n const member = await loadHost(ctx.projectRoot, wrapper.host);\n const specifier = member.host.runner.module;\n const runner = await resolveRunnerModule(ctx.projectRoot, specifier);\n const validated = validateHost(\n runner,\n specifier,\n member.host,\n `hosts/${wrapper.host}/host.js`,\n // build is one-shot: it needs no other member's outputs, so a declared\n // $output stays a token (as in the generic compound).\n { tokens: \"allow\" },\n );\n if (typeof runner.build !== \"function\") {\n console.log(\n `[${host.name}] build: ${name} (${wrapper.host}) exports no build — skipped (packaging builds what is buildable)`,\n );\n continue;\n }\n const fn = getVerb(runner, specifier, \"build\");\n console.log(`[${host.name}] build → ${name} (${wrapper.host})`);\n await fn(validated, {\n ...ctx,\n verb: \"build\",\n parent: { host: host.name, verb: ctx.verb },\n });\n }\n}\n\n/** What the members' plugins need, as the stack resolves them as the project\n * does, from its own node_modules. */\nasync function memberPluginPackages(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<string[]> {\n const projectRequire = createRequire(\n path.join(ctx.projectRoot, \"package.json\"),\n );\n const resolves = (specifier: string) => {\n try {\n projectRequire.resolve(specifier);\n return true;\n } catch {\n return false;\n }\n };\n const packages = new Set<string>();\n for (const wrapper of Object.values(host.children)) {\n const member = await loadHost(ctx.projectRoot, wrapper.host);\n // Connect's plugins are compiled into the build it serves, and all it reads\n // of them at run time is optional. Only a server loads any.\n if (member.host.runner.module === CONNECT_RUNNER) continue;\n const entries = member.host.runner.plugins as PluginEntryData[] | undefined;\n const where = `hosts/${wrapper.host}/host.js`;\n for (const name of pluginPackagesOf(entries ?? [], where, resolves)) {\n packages.add(name);\n }\n }\n return [...packages].sort();\n}\n\n/** The project's own version, which its installers carry. */\nfunction projectVersion(projectRoot: string): string | undefined {\n try {\n const manifest = JSON.parse(\n fs.readFileSync(path.join(projectRoot, \"package.json\"), \"utf8\"),\n ) as { version?: string };\n return manifest.version;\n } catch {\n return undefined;\n }\n}\n\n/** Folds a stack that was just vendored, when the host asks for that. */\nasync function bundleIfAsked(\n staged: { stackDir: string; vendored: boolean },\n asked: boolean | undefined,\n ctx: RunnerContext,\n): Promise<void> {\n if (!staged.vendored) return;\n if (!(asked ?? ctx.env.PH_DESKTOP_BUNDLE_BACKEND === \"1\")) return;\n await bundleBackend({\n stackDir: staged.stackDir,\n logger: (line) => console.log(line),\n });\n}\n\n/** PH_DESKTOP_LOCAL_PACKAGES: tarballs to vendor in place of the registry's\n * (a machine path, so an env var rather than a host-file option). */\nfunction localPackagesDir(ctx: RunnerContext): string | undefined {\n const dir = ctx.env.PH_DESKTOP_LOCAL_PACKAGES;\n return dir ? path.resolve(ctx.projectRoot, dir) : undefined;\n}\n\n/** build = members' builds + the shippable stack + the native installer. */\nexport async function build(\n host: DesktopHost,\n ctx: RunnerContext,\n): Promise<void> {\n await buildMembers(host, ctx);\n\n const runnerOptions = host.runner;\n const mode = shellMode(host, ctx);\n const port = await connectPort(host, ctx);\n\n if (mode === \"generated\") {\n const hostDir = hostDirOf(host, ctx);\n const app = loadAppJson(hostDir);\n const version = projectVersion(ctx.projectRoot);\n const { shellDir, binName, changed } = projectShell({\n hostDir,\n app,\n connectPort: port,\n version,\n });\n const tauri = preflightOrThrow(detectToolchain(ctx.projectRoot), host.name);\n provisionShell(shellDir, tauri, changed);\n // The key reaches tauri through the environment it inherits.\n const signingKey = Boolean(process.env.TAURI_SIGNING_PRIVATE_KEY);\n // Said before the long build: a wrong address ends it here.\n const releaseUrl =\n app.updates && signingKey\n ? releaseBaseUrl(app.updates, version, ctx.env)\n : null;\n\n console.log(`[${host.name}] staging the stack into ${shellDir}…`);\n const staged = bundleStack({\n projectRoot: ctx.projectRoot,\n shellProjectDir: shellDir,\n vendor: runnerOptions.vendorStack,\n phCliVersion: runnerOptions.phCliVersion,\n phCliSpec: runnerOptions.phCliSpec ?? ctx.env.PH_DESKTOP_PHCLI_SPEC,\n localPackagesDir: localPackagesDir(ctx),\n plugins: await memberPluginPackages(host, ctx),\n projectFiles: await memberProjectFiles(host, ctx.projectRoot),\n connectPort: port,\n // the generated shell lives under hosts/ — never stage it into itself\n excludeDirs: [shellDir],\n });\n await bundleIfAsked(staged, runnerOptions.bundleBackend, ctx);\n console.log(\n `[${host.name}] stack staged at ${staged.stackDir}` +\n `${staged.vendored ? \" (ph-run vendored)\" : \"\"}.`,\n );\n\n const bundles = tauriBundlesForHost();\n console.log(\n `[${host.name}] building '${binName}' (${tauri.via}: cargo tauri ` +\n `build --bundles ${bundles.join(\",\")})…`,\n );\n if (app.updates && !signingKey) {\n console.warn(\n `[${host.name}] app.json turns updates on, but TAURI_SIGNING_PRIVATE_KEY ` +\n `is not set: this build is not signed, so it cannot be offered as an ` +\n `update. Set the key to build a release.`,\n );\n }\n const started = Date.now();\n const result = spawnSyncTauri(\n tauri,\n tauriBuildArgs(bundles, {\n on: Boolean(app.updates),\n signingKey,\n unsignedConf: UNSIGNED_BUILD_CONF,\n }),\n shellDir,\n );\n const bundleDir = path.join(shellDir, \"target\", \"release\", \"bundle\");\n // Before the build's own verdict: a build that made the .deb and then\n // failed on the AppImage still has a release for the .deb.\n if (app.updates && signingKey) {\n const release = collectRelease({\n bundleDir,\n productName: app.productName,\n version: bundleVersion(version),\n baseUrl: releaseUrl,\n since: started,\n });\n for (const line of releaseReport(release, releaseUrl)) {\n console.log(`[${host.name}] ${line}`);\n }\n }\n if (result !== 0) {\n throw new Error(\n `hosts/${host.name}: \\`cargo tauri build\\` failed (exit ${result}).`,\n );\n }\n console.log(\n `[${host.name}] desktop app built — installers under ${bundleDir}.`,\n );\n return;\n }\n\n // external-project / external-env: stage into the prebuilt shell (phase 6).\n if (mode === \"none\") {\n console.log(\n `[${host.name}] build: no shell configured — members built; shell ` +\n `packaging skipped (add ${APP_JSON_FILE} or set runner.shell.project).`,\n );\n return;\n }\n const shell = resolveShell(ctx.projectRoot, runnerOptions.shell, ctx.env);\n console.log(`[${host.name}] staging the stack into ${shell.projectDir}…`);\n const result = bundleStack({\n projectRoot: ctx.projectRoot,\n shellProjectDir: shell.projectDir,\n vendor: runnerOptions.vendorStack,\n phCliVersion: runnerOptions.phCliVersion,\n phCliSpec: runnerOptions.phCliSpec ?? ctx.env.PH_DESKTOP_PHCLI_SPEC,\n localPackagesDir: localPackagesDir(ctx),\n plugins: await memberPluginPackages(host, ctx),\n projectFiles: await memberProjectFiles(host, ctx.projectRoot),\n connectPort: port,\n });\n await bundleIfAsked(result, runnerOptions.bundleBackend, ctx);\n console.log(\n `[${host.name}] stack staged at ${result.stackDir}` +\n `${result.vendored ? \" (ph-run vendored)\" : \"\"} — the shell runs it with ` +\n `no environment (resources fallback).`,\n );\n}\n\n/** Synchronous `<tauri> <subcommand>` — build blocks until the installer is\n * produced. Returns the exit code. */\nfunction spawnSyncTauri(\n tauri: TauriCommand,\n subcommand: string[],\n shellDir: string,\n): number {\n const { command, args, shell } = tauriSpawn(tauri, subc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