51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
#!/usr/bin/env node
|
|
/**
|
|
* Build KiraTV and package only a .deb for the current machine architecture.
|
|
* Temporarily narrows electron-builder linux targets, then restores config.
|
|
*/
|
|
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 debArchFromNode() {
|
|
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 = debArchFromNode();
|
|
config.linux = config.linux ?? {};
|
|
config.linux.target = [{ target: 'deb', 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(
|
|
'\nPaquete .deb generado en dist/executables (busca kiratv-*-linux-*.deb).\n'
|
|
);
|
|
} finally {
|
|
fs.writeFileSync(configPath, original);
|
|
}
|