fix(desktop): preserve Tauri runner arguments

On-behalf-of: mahanti <arjun.mahanti@gmail.com>
Signed-off-by: Fizz <dae5f6af70b8695a8b83c8deae555f63be41630ec2b8cd493e41a439c9527dd8@buzz.block.builderlab.xyz>
This commit is contained in:
Fizz
2026-08-31 15:51:46 -04:00
parent 80ee86051e
commit 0ae4abab45
2 changed files with 46 additions and 12 deletions

View File

@@ -43,7 +43,11 @@ export function runTauriCommand(args) {
const outputOverride = JSON.stringify({ build: { frontendDist } });
try {
return runTauri([...args, "--config", outputOverride], {
const delimiterIndex = args.indexOf("--");
const configIndex = delimiterIndex === -1 ? args.length : delimiterIndex;
const tauriArgs = [...args];
tauriArgs.splice(configIndex, 0, "--config", outputOverride);
return runTauri(tauriArgs, {
env: { BUZZ_PROTECTED_BUILD_OUTPUT: frontendDist },
});
} finally {

View File

@@ -25,22 +25,29 @@ mkdirSync(output, { recursive: true });
writeFileSync(path.join(output, "variant.txt"), process.env.VITE_BUZZ_BESTIE);
await new Promise((resolve) => setTimeout(resolve, 100));
const observed = readFileSync(path.join(output, "variant.txt"), "utf8");
writeFileSync(process.env.BUZZ_TEST_RESULT, JSON.stringify({ output, observed }));
writeFileSync(
process.env.BUZZ_TEST_RESULT,
JSON.stringify({ args, output, observed }),
);
`,
);
function packageVariant(variant, result) {
function packageVariant(variant, result, runnerArguments = []) {
return new Promise((resolve, reject) => {
const child = spawn(process.execPath, [wrapper, "build"], {
cwd: desktopRoot,
env: {
...process.env,
BUZZ_TAURI_CLI_ENTRYPOINT: fakeCli,
BUZZ_TEST_RESULT: result,
VITE_BUZZ_BESTIE: variant,
const child = spawn(
process.execPath,
[wrapper, "build", ...runnerArguments],
{
cwd: desktopRoot,
env: {
...process.env,
BUZZ_TAURI_CLI_ENTRYPOINT: fakeCli,
BUZZ_TEST_RESULT: result,
VITE_BUZZ_BESTIE: variant,
},
stdio: "inherit",
},
stdio: "inherit",
});
);
child.once("error", reject);
child.once("exit", (code) =>
code === 0 ? resolve() : reject(new Error(`wrapper exited ${code}`)),
@@ -65,3 +72,26 @@ test("opposite Tauri package variants own private frontend artifacts", async ()
assert.equal(internal.observed, "1");
assert.notEqual(oss.output, internal.output);
});
test("private config precedes Cargo runner arguments", async () => {
const result = path.join(
tmpdir(),
`buzz-tauri-runner-arguments-${process.pid}.json`,
);
await packageVariant("0", result, [
"--config",
'{"bundle":{"active":false}}',
"--",
"--locked",
]);
const invocation = JSON.parse(readFileSync(result, "utf8"));
const delimiterIndex = invocation.args.indexOf("--");
const privateConfigIndex = invocation.args.lastIndexOf("--config");
assert.ok(privateConfigIndex < delimiterIndex);
assert.equal(invocation.args[delimiterIndex + 1], "--locked");
assert.equal(
JSON.parse(invocation.args[privateConfigIndex + 1]).build.frontendDist,
invocation.output,
);
});