32 lines
905 B
JavaScript
32 lines
905 B
JavaScript
import { fetchSwordConfCatalog } from './sword-lib.js'
|
|
|
|
const catalog = await fetchSwordConfCatalog()
|
|
const modules = [...catalog.modules.values()]
|
|
.map((entry) => ({
|
|
id: entry.module_id,
|
|
description: scalar(entry.conf.Description),
|
|
mod_drv: scalar(entry.conf.ModDrv),
|
|
source_type: scalar(entry.conf.SourceType),
|
|
license: scalar(entry.conf.DistributionLicense),
|
|
lang: scalar(entry.conf.Lang),
|
|
}))
|
|
.sort((a, b) => a.id.localeCompare(b.id))
|
|
|
|
for (const module of modules) {
|
|
console.log([
|
|
module.id.padEnd(24),
|
|
module.mod_drv.padEnd(8),
|
|
module.source_type.padEnd(8),
|
|
module.lang.padEnd(6),
|
|
module.license.padEnd(24),
|
|
module.description,
|
|
].join(' ').trimEnd())
|
|
}
|
|
|
|
console.log(`\n${modules.length} SWORD module(s) listed from ${catalog.source_url}`)
|
|
|
|
function scalar(value) {
|
|
if (Array.isArray(value)) return value.join(', ')
|
|
return value ?? ''
|
|
}
|