mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-09-13 05:16:18 -07:00
feat(launcher): bundle a private Bun runtime
This commit is contained in:
@@ -148,3 +148,32 @@ test('runUpdateCommand keeps app-mediated update path on non-Linux', async () =>
|
||||
'remove:/tmp/subminer-update-test',
|
||||
]);
|
||||
});
|
||||
|
||||
test('managed launcher passes its wrapper to app updates, protecting signed resources', async () => {
|
||||
const previous = process.env.SUBMINER_LAUNCHER_PATH;
|
||||
process.env.SUBMINER_LAUNCHER_PATH = '/Users/tester/.local/bin/subminer';
|
||||
try {
|
||||
let forwarded: string[] = [];
|
||||
await runUpdateCommand(
|
||||
makeContext({
|
||||
processAdapter: { ...makeContext().processAdapter, platform: () => 'darwin' },
|
||||
scriptPath: '/Applications/SubMiner.app/Contents/Resources/launcher/subminer',
|
||||
appPath: '/Applications/SubMiner.app/Contents/MacOS/SubMiner',
|
||||
}),
|
||||
{
|
||||
createTempDir: () => '/tmp/subminer-update-test',
|
||||
joinPath: (...parts) => parts.join('/'),
|
||||
runAppCommandCaptureOutput: (_app, args) => {
|
||||
forwarded = args;
|
||||
return { status: 0, stdout: '', stderr: '' };
|
||||
},
|
||||
waitForUpdateResponse: async () => ({ ok: true }),
|
||||
removeDir: () => {},
|
||||
},
|
||||
);
|
||||
assert.equal(forwarded[2], '/Users/tester/.local/bin/subminer');
|
||||
} finally {
|
||||
if (previous === undefined) delete process.env.SUBMINER_LAUNCHER_PATH;
|
||||
else process.env.SUBMINER_LAUNCHER_PATH = previous;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -105,12 +105,17 @@ async function runDirectReleaseUpdate(
|
||||
appImagePath: request.appPath,
|
||||
downloadAsset,
|
||||
}),
|
||||
updateLauncherFromRelease({
|
||||
release,
|
||||
sha256Sums,
|
||||
launcherPath: request.launcherPath,
|
||||
downloadAsset,
|
||||
}),
|
||||
process.env.SUBMINER_MANAGED_LAUNCHER === '1'
|
||||
? Promise.resolve({
|
||||
status: 'skipped',
|
||||
message: 'This launcher is updated with the SubMiner app.',
|
||||
})
|
||||
: updateLauncherFromRelease({
|
||||
release,
|
||||
sha256Sums,
|
||||
launcherPath: request.launcherPath,
|
||||
downloadAsset,
|
||||
}),
|
||||
updateSupportAssetsFromRelease({
|
||||
release,
|
||||
sha256Sums,
|
||||
@@ -203,6 +208,7 @@ export async function runUpdateCommand(
|
||||
return true;
|
||||
}
|
||||
|
||||
const launcherPath = path.resolve(process.env.SUBMINER_LAUNCHER_PATH ?? scriptPath);
|
||||
const tempDir = resolvedDeps.createTempDir('subminer-update-');
|
||||
const responsePath = resolvedDeps.joinPath(tempDir, 'response.json');
|
||||
|
||||
@@ -210,7 +216,7 @@ export async function runUpdateCommand(
|
||||
const result = resolvedDeps.runAppCommandCaptureOutput(appPath, [
|
||||
'--update',
|
||||
'--update-launcher-path',
|
||||
scriptPath,
|
||||
launcherPath,
|
||||
'--update-response-path',
|
||||
responsePath,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user