53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Build KiraTV and package .deb + AppImage for the current machine architecture.
|
|
*/
|
|
import { execSync } from 'node:child_process';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const workspaceRoot = path.resolve(__dirname, '..', '..');
|
|
const configPath = path.join(workspaceRoot, 'electron-builder.json');
|
|
|
|
function linuxArchFromNode() {
|
|
switch (process.arch) {
|
|
case 'arm64':
|
|
return 'arm64';
|
|
case 'arm':
|
|
return 'armv7l';
|
|
default:
|
|
return 'x64';
|
|
}
|
|
}
|
|
|
|
const original = fs.readFileSync(configPath, 'utf8');
|
|
const config = JSON.parse(original);
|
|
|
|
const arch = linuxArchFromNode();
|
|
config.linux = config.linux ?? {};
|
|
config.linux.target = [
|
|
{ target: 'deb', arch: [arch] },
|
|
{ target: 'AppImage', arch: [arch] },
|
|
];
|
|
|
|
fs.writeFileSync(configPath, JSON.stringify(config, null, 4) + '\n');
|
|
|
|
const run = (cmd) => {
|
|
execSync(cmd, { stdio: 'inherit', cwd: workspaceRoot, env: process.env });
|
|
};
|
|
|
|
try {
|
|
const nx = path.join(workspaceRoot, 'node_modules', '.bin', 'nx');
|
|
const nxCmd = fs.existsSync(nx) ? `"${nx}"` : 'npx nx';
|
|
run(`${nxCmd} run electron-backend:build --configuration=kiratv`);
|
|
run(`${nxCmd} run electron-backend:make --configuration=kiratv`);
|
|
|
|
console.log(
|
|
'\nPaquetes generados en dist/executables: .deb y .AppImage (kiratv-*-linux-*).\n'
|
|
);
|
|
} finally {
|
|
fs.writeFileSync(configPath, original);
|
|
}
|