test: add comprehensive Curio installation and runtime fixtures
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { copyFile, cp, mkdir, readFile, rm, writeFile } from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { root, run, suite } from './suite.mjs';
|
||||
|
||||
const selected = process.argv[2] ? suite.filter(item => item.directory === process.argv[2]) : suite;
|
||||
if (!selected.length) throw new Error(`Unknown fixture: ${process.argv[2]}`);
|
||||
let nativeBuilt = false;
|
||||
for (const item of selected) {
|
||||
const directory = path.join(root, 'curios', item.directory);
|
||||
const manifest = JSON.parse(await readFile(path.join(directory, 'curio.json'), 'utf8'));
|
||||
if (manifest.backend) {
|
||||
if (process.platform !== 'darwin') throw new Error('Native packages must be built on macOS for the target architecture.');
|
||||
if (!nativeBuilt) {
|
||||
run('cargo', ['build', '--manifest-path', 'shared/backend/Cargo.toml', '--release', '--locked']);
|
||||
nativeBuilt = true;
|
||||
}
|
||||
const destination = path.join(directory, manifest.backend.entry);
|
||||
await mkdir(path.dirname(destination), { recursive: true });
|
||||
await copyFile(path.join(root, 'shared/backend/target/release/trove-qa-backend'), destination);
|
||||
}
|
||||
if (manifest.ui) {
|
||||
const ui = path.join(directory, 'dist/ui');
|
||||
await rm(ui, { recursive: true, force: true });
|
||||
await mkdir(ui, { recursive: true });
|
||||
await cp(path.join(root, 'shared/ui'), ui, { recursive: true });
|
||||
const sdk = path.dirname(fileURLToPath(import.meta.resolve('@trove/plugin-sdk')));
|
||||
await cp(sdk, path.join(ui, 'sdk'), { recursive: true });
|
||||
await writeFile(path.join(ui, 'config.js'), `export default ${JSON.stringify({ ...item, id: manifest.id, name: manifest.name, version: manifest.version })};\n`);
|
||||
}
|
||||
console.log(`Built ${item.directory} (${manifest.version})`);
|
||||
}
|
||||
Reference in New Issue
Block a user