mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-11 12:12:55 +00:00
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
// @ts-check
|
|
import {readFile} from 'fs/promises';
|
|
|
|
/**
|
|
* @example version(1, import.meta.url)
|
|
* @param options {Omit<import('@openstapps/core').SCAppVersionInfo, 'releaseNotes' | 'translations'>}
|
|
* @param base {string}
|
|
* @returns {Promise<import('@openstapps/core').SCAppVersionInfo>}
|
|
*/
|
|
export async function version(options, base) {
|
|
const de = await readFile(new URL(`${options.version}.de.md`, base), 'utf8');
|
|
const en = await readFile(new URL(`${options.version}.en.md`, base), 'utf8');
|
|
|
|
return {
|
|
...options,
|
|
releaseNotes: de,
|
|
translations: {
|
|
en: {
|
|
releaseNotes: en,
|
|
},
|
|
},
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @param infos {Record<string, import('@openstapps/core').SCAppVersionInfo['published']>}
|
|
* @param base {string} Base path of the file as `import.meta.url`
|
|
* @returns {Promise<import('@openstapps/core').SCAppVersionInfo[]>}
|
|
*/
|
|
export async function versions(infos, base) {
|
|
return Promise.all(
|
|
Object.entries(infos).map(([versionName, published]) =>
|
|
version(
|
|
{
|
|
published,
|
|
version: versionName,
|
|
},
|
|
base,
|
|
),
|
|
),
|
|
).then(it => it.sort(({version: a}, {version: b}) => -a.localeCompare(b, undefined, {numeric: true})));
|
|
}
|