Proyecto App Linux
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Windows only: download bundled VLC, patch electron-builder to ship resources/vlc,
|
||||
* then build KiraTV NSIS installer (x64).
|
||||
*/
|
||||
import { execSync } from 'node:child_process';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
console.error(
|
||||
'Este script debe ejecutarse en Windows (Node win32).\n' +
|
||||
'Para generar el .exe con VLC embebido, usa una máquina Windows o un job windows-latest en CI.'
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const workspaceRoot = path.resolve(__dirname, '..', '..');
|
||||
const configPath = path.join(workspaceRoot, 'electron-builder.json');
|
||||
|
||||
execSync(`node "${path.join(__dirname, 'download-vlc-windows.mjs')}"`, {
|
||||
stdio: 'inherit',
|
||||
cwd: workspaceRoot,
|
||||
});
|
||||
|
||||
const vlcExe = path.join(
|
||||
workspaceRoot,
|
||||
'tools',
|
||||
'packaging',
|
||||
'bundled-vlc',
|
||||
'win64',
|
||||
'vlc.exe'
|
||||
);
|
||||
if (!fs.existsSync(vlcExe)) {
|
||||
console.error('Missing bundled VLC after download:', vlcExe);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const original = fs.readFileSync(configPath, 'utf8');
|
||||
const config = JSON.parse(original);
|
||||
|
||||
const baseExtra = Array.isArray(config.extraResources)
|
||||
? config.extraResources
|
||||
: config.extraResources
|
||||
? [config.extraResources]
|
||||
: [];
|
||||
|
||||
config.extraResources = [
|
||||
...baseExtra.filter((e) => {
|
||||
if (typeof e === 'string') {
|
||||
return !String(e).includes('bundled-vlc');
|
||||
}
|
||||
if (e && typeof e === 'object' && e.to === 'vlc') {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}),
|
||||
{
|
||||
from: 'tools/packaging/bundled-vlc/win64',
|
||||
to: 'vlc',
|
||||
filter: ['**/*'],
|
||||
},
|
||||
];
|
||||
|
||||
config.win = config.win ?? {};
|
||||
config.win.target = [{ target: 'nsis', arch: ['x64'] }];
|
||||
|
||||
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`);
|
||||
// On Windows, Nx defaults to the Windows platform. Do not pass --platform/--arch:
|
||||
// Nx forwards them to dependency targets (web, remote-control-web) and breaks.
|
||||
run(`${nxCmd} run electron-backend:make --configuration=kiratv`);
|
||||
|
||||
console.log(
|
||||
'\nInstalador NSIS generado en dist/executables (kiratv-*-windows-x64-setup.exe) con VLC en resources/vlc.\n'
|
||||
);
|
||||
} finally {
|
||||
fs.writeFileSync(configPath, original);
|
||||
}
|
||||
Reference in New Issue
Block a user