2024-05-20 11:54:37 +02:00
|
|
|
import { readFile, writeFile } from 'node:fs/promises';
|
2022-02-23 11:01:43 +01:00
|
|
|
import { XMLParser, XMLBuilder } from 'fast-xml-parser';
|
2023-04-08 16:51:09 +02:00
|
|
|
import { DateTime } from 'luxon';
|
2022-02-23 11:01:43 +01:00
|
|
|
|
|
|
|
const xmlUrl = new URL('../no.mifi.losslesscut.appdata.xml', import.meta.url);
|
|
|
|
const xmlData = await readFile(xmlUrl);
|
|
|
|
|
2024-03-21 16:28:25 +01:00
|
|
|
const packageJson = JSON.parse(await readFile(new URL('../package.json', import.meta.url)) as unknown as string);
|
2022-02-23 11:01:43 +01:00
|
|
|
|
|
|
|
const parser = new XMLParser({ alwaysCreateTextNode: true, ignoreAttributes: false, ignoreDeclaration: false });
|
|
|
|
const xml = parser.parse(xmlData);
|
|
|
|
// console.log(xml);
|
|
|
|
|
|
|
|
const { version } = packageJson;
|
|
|
|
|
2023-04-08 16:51:09 +02:00
|
|
|
xml.component.releases.release = [{ '@_version': version, '@_date': DateTime.now().toISODate() }, ...xml.component.releases.release];
|
2022-02-23 11:01:43 +01:00
|
|
|
|
|
|
|
const builder = new XMLBuilder({ format: true, ignoreAttributes: false, suppressEmptyNode: true });
|
|
|
|
await writeFile(xmlUrl, builder.build(xml));
|