85 lines
3.6 KiB
JavaScript
85 lines
3.6 KiB
JavaScript
#!/usr/bin/env node
|
|
/*
|
|
* Nieuwe versie maken voor je eigen Homebrew Channel-bron.
|
|
*
|
|
* npm run release -> versie +1 (1.0.0 -> 1.0.1)
|
|
* npm run release -- 1.2.0 -> een vaste versie
|
|
*
|
|
* Daarna: git add -A && git commit -m "versie x" && git push
|
|
* Het Homebrew Channel op de tv toont dan een update.
|
|
*/
|
|
'use strict';
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const crypto = require('crypto');
|
|
const { execFileSync } = require('child_process');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const APP = path.join(ROOT, 'app');
|
|
const REPO = path.join(ROOT, 'repo');
|
|
const cfg = JSON.parse(fs.readFileSync(path.join(ROOT, 'repo.config.json'), 'utf8'));
|
|
|
|
if (!cfg.baseUrl || cfg.baseUrl.indexOf('GITEA-ADRES') >= 0) {
|
|
console.error('Vul eerst "baseUrl" in repo.config.json in (de raw-URL van de map repo/ in Gitea).');
|
|
process.exit(1);
|
|
}
|
|
const base = cfg.baseUrl.endsWith('/') ? cfg.baseUrl : cfg.baseUrl + '/';
|
|
|
|
// 1. versie bepalen en in appinfo.json zetten
|
|
const infoPath = path.join(APP, 'appinfo.json');
|
|
const info = JSON.parse(fs.readFileSync(infoPath, 'utf8'));
|
|
let version = process.argv[2];
|
|
if (!version) {
|
|
const p = info.version.split('.').map(Number);
|
|
p[2] = (p[2] || 0) + 1;
|
|
version = p.join('.');
|
|
}
|
|
if (!/^\d+\.\d+\.\d+$/.test(version)) { console.error('Versie moet x.y.z zijn, bijv. 1.0.1'); process.exit(1); }
|
|
info.version = version;
|
|
fs.writeFileSync(infoPath, JSON.stringify(info, null, 2) + '\n');
|
|
|
|
// 2. oude ipk's weghalen en opnieuw inpakken
|
|
fs.mkdirSync(REPO, { recursive: true });
|
|
fs.readdirSync(REPO).filter(f => f.endsWith('.ipk')).forEach(f => fs.unlinkSync(path.join(REPO, f)));
|
|
const ares = path.join(ROOT, 'node_modules', '.bin', process.platform === 'win32' ? 'ares-package.cmd' : 'ares-package');
|
|
execFileSync(ares, [APP, '-o', REPO], { stdio: 'inherit', shell: process.platform === 'win32' });
|
|
const ipk = fs.readdirSync(REPO).find(f => f.endsWith('.ipk'));
|
|
if (!ipk) { console.error('Inpakken mislukt: geen .ipk gevonden.'); process.exit(1); }
|
|
const sha256 = crypto.createHash('sha256').update(fs.readFileSync(path.join(REPO, ipk))).digest('hex');
|
|
|
|
// 3. pictogram en de twee JSON-bestanden die het Homebrew Channel leest
|
|
fs.copyFileSync(path.join(APP, info.largeIcon || info.icon), path.join(REPO, 'icon.png'));
|
|
const manifestName = info.id + '.manifest.json';
|
|
const manifest = {
|
|
id: info.id,
|
|
version: version,
|
|
type: 'web',
|
|
title: info.title,
|
|
appDescription: 'Eigen IPTV-speler met zenderfilter en tv-gids',
|
|
iconUri: base + 'icon.png',
|
|
sourceUrl: cfg.sourceUrl || '',
|
|
rootRequired: false,
|
|
ipkUrl: base + ipk, // absoluut: het Homebrew Channel lost dit op t.o.v. de ongewijzigde manifestUrl
|
|
ipkHash: { sha256: sha256 }
|
|
};
|
|
fs.writeFileSync(path.join(REPO, manifestName), JSON.stringify(manifest, null, 2) + '\n');
|
|
|
|
const apps = {
|
|
paging: { page: 1, count: 1, maxPage: 1, itemsTotal: 1, itemsPerPage: 1 },
|
|
packages: [{
|
|
id: info.id,
|
|
title: info.title,
|
|
iconUri: base + 'icon.png', // moet absoluut zijn: de lijst lost hem niet zelf op
|
|
manifestUrl: base + manifestName, // absoluut, zie ipkUrl
|
|
version: version,
|
|
shortDescription: '<p>Eigen IPTV-speler met zenderfilter en tv-gids (versie ' + version + ').</p>',
|
|
category: 'multimedia',
|
|
pool: 'main'
|
|
}]
|
|
};
|
|
fs.writeFileSync(path.join(REPO, 'apps.json'), JSON.stringify(apps, null, 2) + '\n');
|
|
|
|
console.log('\nKlaar: versie ' + version + ' (' + ipk + ', sha256 ' + sha256.slice(0, 12) + '…)');
|
|
console.log('Bron-URL voor het Homebrew Channel: ' + base + 'apps.json');
|
|
console.log('Nu nog: git add -A && git commit -m "versie ' + version + '" && git push');
|