Ship the browser engine as its own release file
The installer no longer bundles the engine, and the installer script stops when the bundle names it or when the setup file is over 30 MB. pnpm build:browser-engine packages the engine, writes a deterministic ZIP and its record to releases/browser-engine/<version>/, and pins the ZIP in the host. The installer hooks remove the engine folder that 0.1.48 leaves behind, and uninstall removes the downloaded engine.
This commit is contained in:
@@ -9,15 +9,13 @@ import { nextHotfix, releaseVersion } from '../../../scripts/releaseVersion.mjs'
|
||||
const repository = path.resolve('.');
|
||||
const exists = (file: string) => access(file).then(() => true, () => false);
|
||||
|
||||
// A copy of the files that the installer script reads, with a placeholder Browser runtime.
|
||||
// A copy of the files that the installer script reads.
|
||||
async function fixture() {
|
||||
const root = await mkdtemp(path.join(tmpdir(), 'runestone-installer-build-'));
|
||||
for (const file of [...versionFiles, 'src-tauri/tauri.windows.conf.json', 'src-tauri/windows/hooks.nsh']) {
|
||||
await mkdir(path.dirname(path.join(root, file)), { recursive: true });
|
||||
await copyFile(path.join(repository, file), path.join(root, file));
|
||||
}
|
||||
await mkdir(path.join(root, 'src-tauri/browser-engine'), { recursive: true });
|
||||
await writeFile(path.join(root, 'src-tauri/browser-engine/RuneStone-Browser.exe'), '');
|
||||
const before = await Promise.all(versionFiles.map(file => readFile(path.join(root, file), 'utf8')));
|
||||
const current = releaseVersion(JSON.parse(before[0]).version);
|
||||
return { root, before, current, next: releaseVersion(nextHotfix(current.version)) };
|
||||
@@ -78,14 +76,22 @@ test('a completed build sets the version fields only after the installer exists'
|
||||
}));
|
||||
|
||||
test('a failed build leaves the version fields unchanged', () => withFixture(async ({ root, before, next }) => {
|
||||
for (const failure of ['compile', 'version-resource', 'bundle', 'missing setup file']) {
|
||||
for (const failure of ['compile', 'version-resource', 'bundle', 'missing setup file', 'oversized setup file']) {
|
||||
const plan = await planInstallerBuild(root, next.version);
|
||||
if (failure === 'oversized setup file') plan.maxSetupBytes = 4;
|
||||
const staging = path.join(root, 'output', failure.replaceAll(' ', '-'));
|
||||
const steps = buildCommands(plan, path.join(staging, 'tauri.version.json'));
|
||||
let index = 0;
|
||||
await assert.rejects(runInstallerBuild(plan, async () => {
|
||||
if (steps[index++].step === failure) throw Error('The build command failed with exit code 1');
|
||||
}, staging));
|
||||
const attempt = runInstallerBuild(plan, async () => {
|
||||
const step = steps[index++].step;
|
||||
if (step === failure) throw Error('The build command failed with exit code 1');
|
||||
// A setup file over the size limit, as with a bundled browser engine.
|
||||
if (step === 'bundle' && failure === 'oversized setup file') {
|
||||
await mkdir(path.dirname(plan.artifacts.bundled), { recursive: true });
|
||||
await writeFile(plan.artifacts.bundled, 'setup');
|
||||
}
|
||||
}, staging);
|
||||
await assert.rejects(attempt, failure === 'oversized setup file' ? /more than the limit/ : Error);
|
||||
assert.deepEqual(await contents(root), before, 'A failure during ' + failure + ' must restore the version fields.');
|
||||
assert.equal(await exists(plan.artifacts.release), false);
|
||||
assert.equal(await exists(plan.artifacts.metadata), false);
|
||||
@@ -115,7 +121,11 @@ test('the plan stops before a build that breaks the release rules', () => withFi
|
||||
await writeFile(plan.artifacts.release, 'existing');
|
||||
await assert.rejects(planInstallerBuild(root, next.version), /already exists/);
|
||||
await rm(plan.releaseDir, { recursive: true });
|
||||
await rm(path.join(root, 'src-tauri/browser-engine'), { recursive: true });
|
||||
await assert.rejects(planInstallerBuild(root, next.version), /browser runtime is not staged/);
|
||||
// The browser engine is a separate download. The installer must not bundle it.
|
||||
const config = JSON.parse(before[1]);
|
||||
config.bundle.resources = { 'browser-engine/': 'browser-engine/' };
|
||||
await writeFile(tauriConfig, JSON.stringify(config));
|
||||
await assert.rejects(planInstallerBuild(root, next.version), /must not bundle the browser engine/);
|
||||
await writeFile(tauriConfig, before[1]);
|
||||
assert.deepEqual(await contents(root), before);
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user