37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
// Buendelt das Plugin (inkl. "ws") zu com.fojadrachi.playtube.sdPlugin/plugin/index.js.
|
|
// Mit --zip zusaetzlich dist/Playtube-StreamDock-<version>.zip erzeugen.
|
|
import { execFileSync } from 'node:child_process';
|
|
import { mkdirSync, readFileSync, rmSync } from 'node:fs';
|
|
import path from 'node:path';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { build } from 'esbuild';
|
|
|
|
const ROOT = path.dirname(fileURLToPath(import.meta.url));
|
|
const PLUGIN_NAME = 'com.fojadrachi.playtube.sdPlugin';
|
|
const OUTFILE = path.join(ROOT, PLUGIN_NAME, 'plugin', 'index.js');
|
|
const { version } = JSON.parse(readFileSync(path.join(ROOT, 'package.json'), 'utf8'));
|
|
|
|
await build({
|
|
entryPoints: [path.join(ROOT, 'src', 'main.js')],
|
|
outfile: OUTFILE,
|
|
bundle: true,
|
|
platform: 'node',
|
|
target: 'node20',
|
|
format: 'cjs',
|
|
// Optionale native Beschleuniger von "ws" - nicht noetig, ws faellt auf reines JS zurueck.
|
|
external: ['bufferutil', 'utf-8-validate'],
|
|
legalComments: 'none',
|
|
logLevel: 'info',
|
|
});
|
|
|
|
if (process.argv.includes('--zip')) {
|
|
const dist = path.join(ROOT, 'dist');
|
|
const zip = path.join(dist, `Playtube-StreamDock-${version}.zip`);
|
|
mkdirSync(dist, { recursive: true });
|
|
rmSync(zip, { force: true });
|
|
// tar.exe (bsdtar, in Windows 10+ enthalten) kann Zip-Archive schreiben.
|
|
const tar = process.platform === 'win32' ? path.join(process.env.SystemRoot || 'C:\\Windows', 'System32', 'tar.exe') : 'tar';
|
|
execFileSync(tar, ['-a', '-c', '-f', zip, '-C', ROOT, PLUGIN_NAME], { stdio: 'inherit' });
|
|
process.stdout.write(`Paket: ${zip}\n`);
|
|
}
|