feat(companion): export release bundle artifacts for shell packaging
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import { mkdtemp, readFile, rm, stat } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { writeCompanionReleaseBundle } from './releaseBundle.js';
|
||||
|
||||
describe('writeCompanionReleaseBundle', () => {
|
||||
it('writes manifest, launcher script, and README', async () => {
|
||||
const tempDir = await mkdtemp(join(tmpdir(), 'flynn-companion-release-'));
|
||||
const outputDir = join(tempDir, 'bundle');
|
||||
|
||||
const result = await writeCompanionReleaseBundle({
|
||||
outputDir,
|
||||
manifest: {
|
||||
schemaVersion: 1,
|
||||
generatedAt: '2026-02-27T00:00:00.000Z',
|
||||
gateway: { url: 'ws://127.0.0.1:18800', token: 'token-123' },
|
||||
node: {
|
||||
nodeId: 'ios-node',
|
||||
role: 'companion',
|
||||
platform: 'ios',
|
||||
capabilities: ['ui.canvas', 'node.push.register'],
|
||||
},
|
||||
runtime: {
|
||||
heartbeatSeconds: 30,
|
||||
handoffTimeoutMs: 120000,
|
||||
autoReconnect: true,
|
||||
},
|
||||
status: {
|
||||
appVersion: '1.2.3',
|
||||
statusText: 'ready',
|
||||
powerSource: 'battery',
|
||||
},
|
||||
location: {
|
||||
latitude: 37.3349,
|
||||
longitude: -122.009,
|
||||
source: 'gps',
|
||||
},
|
||||
push: {
|
||||
provider: 'apns',
|
||||
token: '0123456789abcdef0123456789abcdef',
|
||||
topic: 'com.flynn.mobile',
|
||||
environment: 'production',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const manifestRaw = await readFile(result.manifestPath, 'utf8');
|
||||
const launcherRaw = await readFile(result.launcherPath, 'utf8');
|
||||
const readmeRaw = await readFile(result.readmePath, 'utf8');
|
||||
const launcherStat = await stat(result.launcherPath);
|
||||
|
||||
expect(JSON.parse(manifestRaw)).toMatchObject({
|
||||
node: { nodeId: 'ios-node', platform: 'ios' },
|
||||
push: { provider: 'apns' },
|
||||
});
|
||||
expect(launcherRaw).toContain('exec flynn');
|
||||
expect(launcherRaw).toContain('--push-token');
|
||||
expect(launcherRaw).toContain('--latitude');
|
||||
expect(readmeRaw).toContain('Flynn Companion Release Bundle');
|
||||
expect((launcherStat.mode & 0o111) !== 0).toBe(true);
|
||||
|
||||
await rm(tempDir, { recursive: true, force: true });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user